KALCULATOR SEDERHANA

               Di sini saya akan menjelaskan cara membuat kalculator sederhana, pertama kita buat form, label, teksbox, dan button, setelah itu kita susun button tersebut sesuai gamar nomor  1, kemudian  rubah nama propertis dan desain lah sesuai keingnan anda seperti pada nomor 2,3, dan 4. Kemudian masukan listing program kedalam propertis yang ada pada form tersebut seperti button seperti pada gambar 5, textbox. Stelah itu coba jalan kan program yang telah di buat.

1.    Pembuatan form, label, teksbox, dan button


2.    Merubah propertis


3.    Mendesain bagian – bagian yang berada dalam form





 4.    Hasil desain dan output dari program yang telah dibuat
 

5.    Listing program yang berada dalam Form, Textbox, dan Button



LISTING PROGRAM


Public Class Form1
    Dim nilai1, nilai2, hasil As Decimal

    Dim sharedoperator As String

    Dim phi As Decimal = 3.1415926535897944

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

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 1

        Else : Txtangka.Text = Txtangka.Text & 1

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 2

        Else : Txtangka.Text = Txtangka.Text & 2

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 3

        Else : Txtangka.Text = Txtangka.Text & 3

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 4

        Else : Txtangka.Text = Txtangka.Text & 4

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 5

        Else : Txtangka.Text = Txtangka.Text & 5

        End If

        Txtangka.Text = Int(Txtangka.Text)
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 6

        Else : Txtangka.Text = Txtangka.Text & 6

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 7

        Else : Txtangka.Text = Txtangka.Text & 7

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 8

        Else : Txtangka.Text = Txtangka.Text & 8

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 9

        Else : Txtangka.Text = Txtangka.Text & 9

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        If Txtangka.Text = "" Then

            Txtangka.Text = 0

        Else : Txtangka.Text = Txtangka.Text & 0

        End If

        Txtangka.Text = Int(Txtangka.Text)

    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        If nilai1 = 0 Then

            nilai1 = Val(Txtangka.Text)

        Else

            nilai1 = nilai1 + Val(Txtangka.Text)

        End If

        sharedoperator = "+"

        Txtangka.Text = 0

    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        If nilai1 = 0 Then

            nilai1 = Val(Txtangka.Text)

        Else

            nilai1 = nilai1 - Val(Txtangka.Text)

        End If

        sharedoperator = "-"

        Txtangka.Text = 0

    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        If nilai1 = 0 Then

            nilai1 = Val(Txtangka.Text)

        Else

            nilai1 = nilai1 * Val(Txtangka.Text)

        End If

        sharedoperator = "*"

        Txtangka.Text = 0

    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        If nilai1 = 0 Then

            nilai1 = Val(Txtangka.Text)

        Else

            nilai1 = nilai1 / Val(Txtangka.Text)

        End If

        sharedoperator = "/"

        Txtangka.Text = 0

    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        If sharedoperator = "+" Then

            hasil = nilai1 + Val(Txtangka.Text)

            Txtangka.Text = hasil

        ElseIf sharedoperator = "-" Then

            hasil = nilai1 - Val(Txtangka.Text)

            Txtangka.Text = hasil

        ElseIf sharedoperator = "*" Then

            hasil = nilai1 * Val(Txtangka.Text)

            Txtangka.Text = hasil

        ElseIf sharedoperator = "/" Then

            hasil = nilai1 / Val(Txtangka.Text)

            Txtangka.Text = hasil
        End If

        nilai1 = 0

    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Me.Close()

    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        Txtangka.Clear()
    End Sub
End Class


Comments (0)