You are on page 1of 2

FUNGSI IF

Option Explicit
Dim Hitung As Double
Private Sub Combo1_Click()
If Combo1.Text = "Merah" Then
Shape1.BackColor = vbRed
MsgBox "Warna Merah Coy....", vbOKOnly + vbInformation, "Latihanku"
End If

If Combo1.Text = "Biru" Then Shape1.BackColor = vbBlue

End Sub

Private Sub Command1_Click()


If Val(Text1.Text) >= 60 Then
Label3.Caption = "LULUS"
Else
Label3.Caption = "TIDAK LULUS"
End If

End Sub
Private Sub Command2_Click()
Hitung = (Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text)) / 3
Label9.Caption = Format(Hitung, "##.##")
If Hitung >= 80 Then
Label10.Caption = "A"
Label11.Caption = "Istimewa"
ElseIf Hitung >= 70 Then
Label10.Caption = "B"
Label11.Caption = "Baik"
ElseIf Hitung >= 60 Then
Label10.Caption = "C"
Label11.Caption = "Cukup"
ElseIf Hitung >= 50 Then
Label10.Caption = "D"
Label11.Caption = "Kurang"
Else
Label10.Caption = "E"
Label11.Caption = "Sangat Kurang"
End If

End Sub

Private Sub Form_Load()


Combo1.AddItem "Merah"
Combo1.AddItem "Biru"
Combo1.AddItem "Hijau"
Combo1.AddItem "Kuning"
Combo1.AddItem "Hitam"

End Sub

You might also like