Visual Basic 2010 Membuat Calculator

//lh3.googleusercontent.com/-K5UKWzgJhmU/AAAAAAAAAAI/AAAAAAAACdI/CN3nwiBZsGE/s512-c/photo.jpg
November 16, 2016





Membuat Calculator VB 2010

 Public Class Form1
    Dim Rumus As String
    Dim Hasil As Object
    Private Property input_angka As Double
    Private Property phi As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Kalkulator
        Const phi As Double = 22 / 7
        Dim input_angka, Hasil As Double
        Dim Rumus As String
    End Sub
    Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
        TextBox1.Text = TextBox1.Text & "0"
    End Sub
    Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
        TextBox1.Text = TextBox1.Text & "1"
    End Sub
    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        TextBox1.Text = TextBox1.Text & "2"
    End Sub
    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        TextBox1.Text = TextBox1.Text & "3"
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox1.Text = TextBox1.Text & "4"
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox1.Text = TextBox1.Text & "5"
    End Sub
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox1.Text = TextBox1.Text & "6"
    End Sub
    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        TextBox1.Text = TextBox1.Text & "7"
    End Sub
    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        TextBox1.Text = TextBox1.Text & "8"
    End Sub
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox1.Text = TextBox1.Text & "9"
    End Sub
    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        input_angka = Val(TextBox1.Text)
        Rumus = "+"
        TextBox1.Text = Nothing
    End Sub
    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Dim Kalkulator
        input_angka = Val(TextBox1.Text)
        Rumus = "-"
        TextBox1.Text = Nothing
    End Sub
    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        input_angka = Val(TextBox1.Text)
        Rumus = "*"
        TextBox1.Text = Nothing
    End Sub
    Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
        input_angka = Val(TextBox1.Text)
        Rumus = "/"
        TextBox1.Text = Nothing
    End Sub
    Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click
        TextBox1.Text = TextBox1.Text & "."
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = Math.Sqrt(TextBox1.Text)
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox1.Text = Math.Cos(TextBox1.Text * (phi / 180))
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = Math.Sin(TextBox1.Text * (phi / 180))
    End Sub
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        TextBox1.Text = Math.Tan(TextBox1.Text * (phi / 180))
    End Sub
    Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
        If Rumus = "+" Then
            TextBox1.Text = input_angka + Val(TextBox1.Text)
        ElseIf Rumus = "-" Then
            TextBox1.Text = input_angka - Val(TextBox1.Text)
        ElseIf Rumus = "*" Then
            TextBox1.Text = input_angka * Val(TextBox1.Text)
        ElseIf Rumus = "/" Then
            TextBox1.Text = input_angka / Val(TextBox1.Text)
        ElseIf Rumus = "^" Then
            TextBox1.Text = input_angka ^ Val(TextBox1.Text)
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = Nothing
        input_angka = Nothing
        Hasil = Nothing
        Rumus = Nothing
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If TextBox1.Text.Length <> 0 Then
            TextBox1.Text = TextBox1.Text.Remove(TextBox1.Text.Length - 1)
        End If
    End Sub
End Class

Semoga ap yang share di atas bermanfaat bagi anda, Jangan lupa share keteman kalian juga supaya kita saling belajar dalam membuatacalculator menggunakan vb 2010.


Related Post

SUBSCRIBE TO OUR NEWSLETTER

closed