1. Buatlah project baru
2. Buatlah Form Baru terdiri dari componen Label1, Label2, Label3, Label4, Label5, Textbox1, Textbox2, Textbox3, Combobox, Commond button1, Commond button2, Commond button3
3. Ganti nama componen yang di buat tadi
componen Label1 = kalkulator sederhana
Label2 = nilai1
Label3 = nilai2
Label4 = operator
Label5 = hasil
Textbox1= nilai1
Textbox2 = nilai2
Textbox3 = hasil
Combobox = combo1
Commond button1 = Hasil
Commond button2 = Reset
Commond button3 = keluar
4.Kemudian masukan kode berikut di setiap masing-masing commond button
Private Sub Hasil_Click()
If Combo1.Text = "+" Then
hasil.Text = nilai1.Text + Val(nilai2.Text)
Else
If Combo1.Text = "x" Then
hasil.Text = nilai1.Text * Val(nilai2.Text)
Else
If Combo1.Text = "-" Then
hasil.Text = nilai1.Text - Val(nilai2.Text)
Else
If Combo1.Text = "/" Then
hasil.Text = nilai1.Text / Val(nilai2.Text)
End If
End If
End If
End If
End Sub
Private Sub Reset_Click()
nilai1.Text = ""
nilai2.Text = ""
hasil.Text = ""
End Sub
Private Sub Keluar_Click()
End
End Sub
Private Sub Form_Load()
Combo1.AddItem ("+")
Combo1.AddItem ("-")
Combo1.AddItem ("x")
Combo1.AddItem ("/")
End Sub
Combo1.AddItem ("+")
Combo1.AddItem ("-")
Combo1.AddItem ("x")
Combo1.AddItem ("/")
End Sub
Selesai
Demikian Semoga Bermanfaat
Hasil Tampilan Run Kalkulator Sederhana