PEROGRAM-PROGRAM SEDERHANA VB
*kakulator sederhana dan operator pembanding
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
Private Sub Command2_Click()
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub
Private Sub Command3_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub
Private Sub Command4_Click()
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub
Private Sub Command5_Click()
Text3.Text = Val(Text1.Text) ^ Val(Text2.Text)
End Sub
Private Sub Option1_Click()
If Text1 < Text2 Then
Text3 = "BENAR"
Else
Text3 = "SALAH"
End If
End Sub
Private Sub Option2_Click()
If Text1 > Text2 Then
Text3 = "BENAR"
Else
Text3 = "SALAH"
End If
End Sub
Private Sub Option3_Click()
If Text1 <= Text2 Then
Text3 = "BENAR"
Else
Text3 = "SALAH"
End If
End Sub
Private Sub Option4_Click()
If Text1 >= Text2 Then
Text3 = "BENAR"
Else
Text3 = "SALAH"
End If
End Sub
Private Sub Option5_Click()
Text3 = Text1 & Text2
End Sub
**PEROGRAM MENCARI BILANGAN GANJIL ATAU GENAP
Private Sub Command1_Click()
'mendeklarasikan pariabel
Dim A As Double
'mengisi A dengan text1
A = Text1
'mengecek mengunakn aritmatika mod apa bila sisa baginya sana dengan 0 maka bilangan genap atau sebaliknya
If A Mod 2 = 0 Then
Text2 = "GENAP"
Else
Text2 = "GANJIL"
End If
Command2.SetFocus
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
End Sub
***PEROGRAM MENGUNAKAN SELECT CASE
Private Sub Command1_Click()
Dim A As Integer
A = Text1
Select Case A
Case 1:
makanan = "mie ayam"
minuman = "air putih"
harga = 6000
Case 2:
makanan = "nasi uduk"
minuman = "segarsari"
harga = 4000
Case 3:
makanan = "nasi campur"
minuman = "jus jambu"
harga = 8000
Case 4:
makanan = "nasi goreng"
minuman = "air putih"
harga = 7000
End Select
If A > 4 Then
MsgBox ("menu yang ada masukan tidak ada pilih 1-4")
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
makanan = ""
minuman = ""
harga = ""
Private Sub Command1_Click()
nama = InputBox("masukan nama anda")
Text1 = nama
alamat = InputBox("masukan alamat anda")
Text2 = alamat
ttl = InputBox("masukan tempat tanggal lahir")
Text3 = ttl
'untuk menampilkan data dengan msgbox
MsgBox "masukan anda : " & Text1 & Chr(10) & "alamat : " & Text2 & Chr(10) & "ttl :" & Text3, vbYesNoCancel
End Sub
***** PROGRAM SELECT CASE
koding :
Private Sub Command1_Click()
Select Case Text1
Case Is >= 90
Text2 = "A"
Case Is >= 80
Text2 = "B"
Case Is >= 70
Text2 = "C"
Case Is < 50
Text2 = "D"
End Select
End Sub
*Perogram Sederhana
Koding :
Private Sub Combo1_Click()
If Combo1.Text = "A" Then
Text1 = "KOMPUTER"
Text2 = 1000000
ElseIf Combo1.Text = "B" Then
Text1 = "MOUSE"
Text2 = 200000
ElseIf Combo1.Text = "C" Then
Text1 = "CPU"
Text2 = 800000
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"
Combo1.AddItem "C"
End Sub
Posting Komentar