Jam

Selasa, 03 Mei 2016

Listing Program perulangan dan percabangan pada Visual basic



LISTING PROGRAM2

Form1
Private Sub Command1_Click()
If Text1.Text = "Rikal" And Text2.Text = "diajeng" Then
MsgBox "Login Sukses", vbInformation, "Login"
Unload Me                                            
Form2.Show
Else
MsgBox "Password Salah", vbCritical, "Failure"
End If
End Sub

Form2
Private Sub Command1_Click()
Unload Me
Form3.Show
End Sub

Private Sub Command2_Click()
Unload Me
Form4.Show
End Sub

Private Sub Command3_Click()
Unload Me
Form5.Show
End Sub

Form3
Private Sub Command1_Click()
x = Val(Text1)
y = 1
List1.Clear
Do
List1.AddItem y
ly = y + 1
Loop Until y > x
End Sub

Private Sub Command2_Click()
Unload Me
Form2.Show
End Sub

Form4
Private Sub Command1_Click()
n = Val(Text1)
List1.Clear
k = 0
bil = 2
While k < n
prima = True
For pembagi = 2 To bil - 1
If bil Mod pembagi = 0 Then prima = False
Next pembagi
If prima Then
List1.AddItem bil
k = k + 1
End If
bil = bil + 1
Wend
End Sub

Private Sub Command2_Click()
Unload Me
Form2.Show
End Sub

Private Sub Command1_Click()
NamaBarang = Val(Text1)
Select Case NamaBarang
Case 110:
Text2.Text = "Televisi Samsung32inch lcd"
Text3.Text = "Rp.5.970.000"
Case 220:
Text2.Text = "Televisi Toshiba29inch led"
Text3.Text = "Rp.3.500.000"
Case 330:
Text2.Text = "Televis Polytron21inch lcd"
Text3.Text = "Rp.1.800.000"
Case 440:
Text2.Text = "Televisi panasonic21inch led"
Text3.Text = "Rp.2.585.000"
Case 550:
Text2.Text = "Televisi Sharp32inch led"
Text3.Text = "Rp.4.700.000"
Case Else
MsgBox "Kode salah", vbCritical, "Fail"
End Select
End Sub

Private Sub Command2_Click()
Unload Me
Form2.Show
End Sub



Tidak ada komentar:

Posting Komentar