Friday, April 12, 2013

How to make simple Calculator with VB.Net



Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click
        Dim a As String = CType(sender, Button).Text
        Dim b As Integer
        If Me.TextBox1.Text = "" Or Me.TextBox2.Text = "" Then
            MsgBox("Kolom Kosong", MsgBoxStyle.Critical, "Warning")
            If a = "C" Then
                Me.TextBox1.Text = ""
                Me.TextBox2.Text = ""
                Me.TextBox3.Text = ""
            End If
        Else
            If IsNumeric(Me.TextBox1.Text) = False Or IsNumeric(Me.TextBox2.Text) = False Then
                MsgBox("Inputan Hanya Berupa Angka", MsgBoxStyle.Exclamation, "Warning")
                If a = "C" Then
                    Me.TextBox1.Text = ""
                    Me.TextBox2.Text = ""
                    Me.TextBox3.Text = ""
                End If

            Else
                If a = "x" Then
                    Me.TextBox3.Text = TextBox1.Text * TextBox2.Text
                    b = CInt(Me.TextBox3.Text)
                    If b >= 0 Then
                        Me.TextBox3.BackColor = Color.Blue
                        Me.TextBox3.Font = New Drawing.Font("Arial", 20, FontStyle.Bold)
                    ElseIf b < -1 Then
                        Me.TextBox3.BackColor = Color.Red
                        Me.TextBox3.Font = New Drawing.Font("Courier New", 10, FontStyle.Italic)
                    End If
                ElseIf a = "/" Then
                    If Me.TextBox1.Text = 0 Or Me.TextBox2.Text = 0 Then
                        MsgBox("Pembagi Tidak Boleh 0", MsgBoxStyle.Critical, "!! Warning !!")
                    Else
                        Me.TextBox3.Text = TextBox1.Text / TextBox2.Text
                        b = CInt(Me.TextBox3.Text)
                        If Me.TextBox3.Text.Length > 4 Then
                            Dim c As String = Me.TextBox3.Text.Substring(0, 4)
                            Me.TextBox3.Text = c
                            If b >= 0 Then
                                Me.TextBox3.BackColor = Color.Blue
                                Me.TextBox3.Font = New Drawing.Font("Arial", 20, FontStyle.Bold)
                            ElseIf b < -1 Then
                                Me.TextBox3.BackColor = Color.Red
                                Me.TextBox3.Font = New Drawing.Font("Courier New", 10, FontStyle.Italic)
                            End If
                        End If
                    End If
                ElseIf a = "+" Then
                    Dim x As Integer = CInt(Me.TextBox1.Text)
                    Dim y As Integer = CInt(Me.TextBox2.Text)
                    Me.TextBox3.Text = x + y
                    b = CInt(Me.TextBox3.Text)
                    If b >= 0 Then
                        Me.TextBox3.BackColor = Color.Blue
                        Me.TextBox3.Font = New Drawing.Font("Arial", 20, FontStyle.Bold)
                    ElseIf b < -1 Then
                        Me.TextBox3.BackColor = Color.Red
                        Me.TextBox3.Font = New Drawing.Font("Courier New", 10, FontStyle.Italic)
                    End If
                ElseIf a = "-" Then
                    Me.TextBox3.Text = TextBox1.Text - TextBox2.Text
                    b = CInt(Me.TextBox3.Text)
                    If b >= 0 Then
                        Me.TextBox3.BackColor = Color.Blue
                        Me.TextBox3.Font = New Drawing.Font("Arial", 20, FontStyle.Bold)
                    ElseIf b < -1 Then
                        Me.TextBox3.BackColor = Color.Red
                        Me.TextBox3.Font = New Drawing.Font("Courier New", 10, FontStyle.Italic)
                    End If
                End If
                If a = "C" Then
                    Me.TextBox1.Text = ""
                    Me.TextBox2.Text = ""
                    Me.TextBox3.Text = ""
                End If
            End If
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

by : 562010008@student.uksw.edu (Watashi no kantan'na memo)

68 comments:

  1. makasih buat tutorialnya ijin mempelajari dulu

    ReplyDelete
    Replies
  2. This is a very significant blog. Thanks for sharing your thoughts. Keep up the good job in posting very good topics.

    ReplyDelete
  3. thanks, i am looking forward to using vb.net soon!

    ReplyDelete
  4. motobola.org
    Agen Bola, Agen Judi, Agen Bola Online, Judi Online, Casino Online, Togel Online, Tangkas Online, Bandar Bola, Agen

    Betting, Poker Online
    Agen Bola
    Agen Judi
    Agen Bola Online
    Judi Online
    Casino Online
    Togel Online
    Tangkas Online
    Bandar Bola
    Agen Betting
    Poker Online
    Berita Bola

    ReplyDelete
  5. http://celebrityoftheworld.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://oesaha.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://mungkindanbo.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://west-java-indonesia.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://iklan-pertama.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://selebriti-nusantara.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://indonesia-lovers.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://j-handycraft.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://pertamadiblogger.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    http://banerbanner.blogspot.com/2014/03/agen-bola-terpercaya-terbaik.html
    go88bet.com Agen Judi, Agen Judi Bola, Agen Bola Online, Agen SBObet Terpercaya
    KAISARBET.COM AGEN BOLA TERPERCAYA PIALA DUNIA 2014
    MASTERPOKER88.COM JUDI POKER ONLINE UANG ASLI INDONESIA RESMI DAN TERPERCAYA

    ReplyDelete
  6. jasa seo google - http://www.jasaseogoogle.web.id
    jasa seo termurah - http://www.jasaseotermurah.web.id
    jasa seo indonesia - http://www.jasaseoindonesia.web.id
    jasa blog - http://www.jasablog.org
    jasa backlink - http://www.jasablog.org/jasa-backlink
    Jasa Toko Online - http://www.jasablog.org/jasa-toko-online
    Jasa SEO - http://www.jasablog.org/jasa-seo
    Jasa Penulisan Artikel - http://www.jasablog.org/jasa-konten
    Jasa Pembuatan Website - http://www.jasablog.org/jasa-pembuatan-website
    jasa brosur - http://www.jasabrosur.com
    Content Artikel - http://www.contentwritter.web.id
    Kabar Selebriti - http://kabarselebriti.com
    Informasi Hewan - http://www.hewan.org
    Tips Menang - http://www.tipsmenang.com

    ReplyDelete
  7. Nowadays the optimism of students who pay for essay writing http://papersmart.net/pay-for-essay.html website for the first time or on a regular basis can make them think in alternative way and meaning. You can hire best writing services that can prove its abilities to compose serious pieces and information for my university this semester.

    ReplyDelete
  8. Having read this I thought it was rather informative. I appreciate you finding the time and energy to put this content together. I once again find myself spending a lot of time both reading and posting comments. But so what, it was still worth it!

    Regards:

    [url]http://www.puribalirentcar.com[/url]

    Cheap Bali Car Hire

    Cheap Car Rental In Bali

    Sewa Mobil Murah Di Bali

    Sewa Mobil Murah Di Bali

    Cheap Bali Car Rental

    Sewa Mobil Di Bali

    Sewa Mobil Bali

    Bali Car Rental

    Penyewaan Mobil Murah Di Bali

    Penyewaan Mobil Di Bali

    Penyewaan Mobil Bali

    Rental Mobil Murah Di Bali

    Rental Mobil Di Bali

    Rental Mobil Bali

    Rent Car Murah Di Bali

    Rent Car Di Bali

    Rent Car Bali

    ReplyDelete
  9. Nice information. I was searching for the same. It helped me alot and saved my time. Thanks alot. upma recipe

    ReplyDelete
  10. welcome to our website here uda rino provides articles kata kata cinta, kata kata mutiara, kata kata lucu, kata kata galau and many other interesting article, thank you!

    ReplyDelete
  11. This information is I really need most
    Thank you very much sharing, Have good day
    Bali Driver and Bali Tours

    ReplyDelete
  12. Terima kasih untuk tutorialnya, ini sangat menarik.
    iklan gratis

    ReplyDelete
  13. ah bangsat loo tai spam semua anjing

    ReplyDelete
  14. It's really interesting for me, thank you so much.
    iklan71

    ReplyDelete