Advertisemen
Kali Ini Kita Akan Membuat Kalkulator Lagi Tapi Dengan Sedikit Perubahan
Kita Akan Menggunakan ComboBox Untuk Memilih Operation nya
Buka VB Dan Pilih Standart.exe
Buat Tampilan Form Seperti Ini
Lalu MAsukan Listing Programnya Di jendela coding
Private Sub Combo1_Click()
If Text1.Text = "" Then
MsgBox "Isi Angka Dulu Bro!!!"
Text1.SetFocus
ElseIf IsNumeric(Text1) = False Then
MsgBox "Harus Angka !!"
Text1.SetFocus
End If
If Text2.Text = "" Then
MsgBox "Isi Angka Dulu Bro!!!"
Text1.SetFocus
ElseIf IsNumeric(Text2) = False Then
MsgBox "Harus Angka !!"
Text2.SetFocus
End If
If Combo1.ListIndex = 0 Then
Label3.Caption = Val(Text1.Text) + Val(Text2.Text)
End If
If Combo1.ListIndex = 1 Then
Label3.Caption = Val(Text1.Text) - Val(Text2.Text)
End If
If Combo1.ListIndex = 2 Then
Label3.Caption = Val(Text1.Text) * Val(Text2.Text)
End If
If Combo1.ListIndex = 3 Then
Label3.Caption = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub
Private Sub Command1_Click()
Text1 = ""
Text2 = ""
Label3 = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Combo1.AddItem "+"
Combo1.AddItem "-"
Combo1.AddItem "x"
Combo1.AddItem "/"
End Sub
Kita Akan Menggunakan ComboBox Untuk Memilih Operation nya
Buka VB Dan Pilih Standart.exe
Buat Tampilan Form Seperti Ini
Saia Menggunaka
-3 Buah Label
-2 Buah Text Box
-1 Buah Command Button
-1 Buah Combo Box
Lalu MAsukan Listing Programnya Di jendela coding
Private Sub Combo1_Click()
If Text1.Text = "" Then
MsgBox "Isi Angka Dulu Bro!!!"
Text1.SetFocus
ElseIf IsNumeric(Text1) = False Then
MsgBox "Harus Angka !!"
Text1.SetFocus
End If
If Text2.Text = "" Then
MsgBox "Isi Angka Dulu Bro!!!"
Text1.SetFocus
ElseIf IsNumeric(Text2) = False Then
MsgBox "Harus Angka !!"
Text2.SetFocus
End If
If Combo1.ListIndex = 0 Then
Label3.Caption = Val(Text1.Text) + Val(Text2.Text)
End If
If Combo1.ListIndex = 1 Then
Label3.Caption = Val(Text1.Text) - Val(Text2.Text)
End If
If Combo1.ListIndex = 2 Then
Label3.Caption = Val(Text1.Text) * Val(Text2.Text)
End If
If Combo1.ListIndex = 3 Then
Label3.Caption = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub
Private Sub Command1_Click()
Text1 = ""
Text2 = ""
Label3 = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Combo1.AddItem "+"
Combo1.AddItem "-"
Combo1.AddItem "x"
Combo1.AddItem "/"
End Sub
Advertisemen