Latihan 1 menggunakan (IF – THEN –ELSE)
Berikut Source Codenya :
Public Class latihan1
'nadiahtami 2017230007
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim keterangan As String
If TextBox1.Text >= 80 Then
keterangan = "Selamat Anda Lulus"
Else
keterangan = "Mohon Maaf Anda Belum Lulus"
End If
TextBox2.Text = keterangan
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pesan As String
pesan = MsgBox("Yakin Ingin Keluar??", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
End
End If
End Sub
End Class
Latihan 2 menggunakan (NESTED- IF)
Berikut Source Codenya :
Public Class latihan2
'nadiahtami 2017230007
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
If ComboBox1.Text = "Garuda" Then
If ComboBox2.Text = "Medan-Padang" Then
TextBox1.Text = 500000
ElseIf ComboBox2.Text = "Medan-Jakarta" Then
TextBox1.Text = 1000000
ElseIf ComboBox2.Text = "Medan-Bali" Then
TextBox1.Text = 1500000
End If
ElseIf ComboBox1.Text = "Lion" Then
If ComboBox2.Text = "Medan-Padang" Then
TextBox1.Text = 300000
ElseIf ComboBox2.Text = "Medan-Jakarta" Then
TextBox1.Text = 600000
ElseIf ComboBox2.Text = "Medan-Bali" Then
TextBox1.Text = 800000
End If
ElseIf ComboBox1.Text = "Sriwijaya" Then
If ComboBox2.Text = "Medan-Padang" Then
TextBox1.Text = 400000
ElseIf ComboBox2.Text = "Medan-Jakarta" Then
TextBox1.Text = 800000
ElseIf ComboBox2.Text = "Medan-Bali" Then
TextBox1.Text = 1000000
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pesan As String
pesan = MsgBox("Yakin Ingin Keluar??", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
End
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ComboBox1.Text = ""
ComboBox2.Text = ""
TextBox1.Text = ""
End Sub
End Class
Komentar
Posting Komentar