Praktek Pogram Membuat Kalkulator Sederhana

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

PRAKTIKUM

Contoh : Pogram Membuat Kalkulator


Buat Form seperti dibawah ini dengan menggunakan Microsoft Visual Studio VB.Net

Caranya :

Buat :

1. label "Kalkulator Sederhana"


2. textbox = txtinput
3. Tombol 1 = button1
4. Tombol 2 = button2
5. Tombol 3 = button3
6. Tombol 4 = button4
7. Tombol 5 = button5
8. Tombol 6 = button6
9. Tombol 7 = button7
10. Tombol 8 = button8
11. Tombol 9 = button9
12. Tombol 0 = button0
13. Tombol 00 = button10
14. Tombol . = button11
15. Tombol = = buttonsamadengan
16. Tombol X = buttonkali
17. Tombol : = buttonbagi
18. Tombol + = buttontambah
19. Tombol - = buttonkurang
20. Tombol Exit = button12
21. Tombol Del = buttonhapus

Koding Programnya.
Public Class Form1
Dim num1, num2 As Double
Dim opr As String

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 Txtinput.Text <> "0" Then
Txtinput.Text += "1"
Else
Txtinput.Text = "1"
End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "2"
Else
Txtinput.Text = "2"
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "3"
Else
Txtinput.Text = "3"
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "4"
Else
Txtinput.Text = "4"
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "5"
Else
Txtinput.Text = "5"
End If
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button6.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "6"
Else
Txtinput.Text = "6"
End If
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button7.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "7"
Else
Txtinput.Text = "7"
End If
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button8.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "8"
Else
Txtinput.Text = "8"
End If
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button9.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "9"
Else
Txtinput.Text = "9"
End If
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button11.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "0"
Else
Txtinput.Text = "0"
End If
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button10.Click
If Txtinput.Text <> "0" Then
Txtinput.Text += "00"
Else
Txtinput.Text = "00"
End If
End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button13.Click
num1 = Txtinput.Text
Txtinput.Text = ""
opr = "*"

End Sub

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button17.Click
num2 = Txtinput.Text
If opr = "*" Then
Txtinput.Text = num1 * num2
ElseIf opr = "/" Then
Txtinput.Text = num1 / num2
ElseIf opr = "+" Then
Txtinput.Text = num1 + num2
ElseIf opr = "-" Then
Txtinput.Text = num1 - num2
Else
MsgBox("ADA YANG SALAH")
End If

End Sub

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button18.Click
Txtinput.Clear()
End Sub

Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button19.Click
End
End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button14.Click
num1 = Txtinput.Text
Txtinput.Text = ""
opr = "/"

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button15.Click
num1 = Txtinput.Text
Txtinput.Text = ""
opr = "+"

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button16.Click
num1 = Txtinput.Text
Txtinput.Text = ""
opr = "-"

End Sub
End Class

SETELAH DI RUN HASILNYA SEPERTI INI

You might also like