Private Sub Command1_Click()
If Text1.Text = “CPU” Then
Text2.Text = “Central Processing Unit”
Text3.Text = “275000″
ElseIf Text1.Text = “RAM” Then
Text2.Text = “Random Access Memory”
Text3.Text = “225000″
ElseIf Text1.Text = “HDD” Then
Text2.Text = “Hard Disk”
Text3.Text = “425000″
ElseIf Text1.Text = “MTR” Then
Text2.Text = “Monitor”
Text3.Text = “750000″
ElseIf Text1.Text = “CDR” Then
Text2.Text = “Cd Room”
Text3.Text = “175000″
ElseIf Text1.Text = “PRT” Then
Text2.Text = “Printer”
Text3.Text = “500000″
End If
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Text7.Text = (Text3.Text) * (Text4.Text)
Text6.ForeColor = vbBlue
If Text7.Text >= 2000000 Then
Option1.Value = True
Option2.Value = False
Option3.Value = False
Option4.Value = False
Text5.Text = “20″
Text6.Text = (Text7.Text) – ((Text7.Text) * (Text5.Text) / 100)
ElseIf (Text7.Text < 2000000) And (Text7.Text > 1000000) Then
Option1.Value = False
Option2.Value = True
Option3.Value = False
Option4.Value = False
Text5.Text = “10″
Text6.Text = (Text7.Text) – ((Text7.Text) * (Text5.Text) / 100)
ElseIf (Text7.Text < 1000000) And (Text7.Text > 500000) Then
Option1.Value = False
Option2.Value = False
Option3.Value = True
Option4.Value = False
Text5.Text = “5″
Text6.Text = (Text7.Text) – ((Text7.Text) * (Text5.Text) / 100)
ElseIf Text7.Text < 500000 Then
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = True
Text5.Text = “0″
Text6.Text = Val(Text7.Text)
End If
End Sub
Private Sub Command5_Click()
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
End Sub
Private Sub Command6_Click()
Text4.Text = “”
Text7.Text = “”
End Sub
Private Sub Command7_Click()
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
Text4.Text = “”
Text5.Text = “”
Text6.Text = “”
Text7.Text = “”
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
End Sub
Karena contoh tersebut mempunyai lebih dari 2 pengulangan, maka saya menggunakan contoh dari pengulangan If .. Then .. Else ..
pengulangan tersebut bisa melakukan pengulangan lebih dari 2 pengulangan.
Akan tampil seperti gambar di bawah ini……
No comments:
Post a Comment