Soal :
Buatlah program berdasarkan tabel dibawah ini :
Untuk mencari Nama :
N = Nokia
C = Seemen
S = Samsung
Listing Program :
Public Class Form_UTS
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Tipe.Items.Add("N70")
Tipe.Items.Add("N71")
Tipe.Items.Add("N95")
Tipe.Items.Add("C45")
Tipe.Items.Add("S611")
Tahun.Items.Add("2008")
Tahun.Items.Add("2009")
Tahun.Items.Add("2010")
Tahun.Items.Add("2011")
Nama.ReadOnly = True
Harga.ReadOnly = True
Total_Harga.ReadOnly = True
Tipe.Focus()
Btn_Hapus.Text = "Hapus"
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tipe.SelectedIndexChanged
Dim a As String
a = Microsoft.VisualBasic.Left(Tipe.Text, 1)
Select Case a
Case "N" : Me.Nama.Text = "Nokia"
Case "C" : Me.Nama.Text = "Seemen"
Case "S" : Me.Nama.Text = "Samsung"
End Select
Tahun.Focus()
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tahun.SelectedIndexChanged
Select Case Tahun.Text
Case "2008"
Select Case Tipe.Text
Case "N70" : Me.Harga.Text = 2000000
Case "N71" : Me.Harga.Text = 2100000
Case "N95" : Me.Harga.Text = 2200000
Case "C45" : Me.Harga.Text = 2300000
Case "S611" : Me.Harga.Text = 2400000
End Select
Case "2009"
Select Case Tipe.Text
Case "N70" : Me.Harga.Text = 2200000
Case "N71" : Me.Harga.Text = 2300000
Case "N95" : Me.Harga.Text = 2400000
Case "C45" : Me.Harga.Text = 2500000
Case "S611" : Me.Harga.Text = 2600000
End Select
Case "2010"
Select Case Tipe.Text
Case "N70" : Me.Harga.Text = 2400000
Case "N71" : Me.Harga.Text = 2500000
Case "N95" : Me.Harga.Text = 2600000
Case "C45" : Me.Harga.Text = 2700000
Case "S611" : Me.Harga.Text = 2800000
End Select
Case "2011"
Select Case Tipe.Text
Case "N70" : Me.Harga.Text = 2300000
Case "N71" : Me.Harga.Text = 2600000
Case "N95" : Me.Harga.Text = 2900000
Case "C45" : Me.Harga.Text = 2120000
Case "S611" : Me.Harga.Text = 2150000
End Select
End Select
Jumlah_Beli.Focus()
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah_Beli.KeyPress
If Asc(e.KeyChar) = 13 Then
Total_Harga.Text = Harga.Text * Jumlah_Beli.Text
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Hapus.Click
Tipe.Text = ""
Tahun.Text = ""
Harga.Text = ""
Nama.Text = ""
Jumlah_Beli.Text = ""
Total_Harga.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Keluar.Click
Dim i As MsgBoxResult
i = MsgBox("Apa anda ingin keluar?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Perhatian")
If i = MsgBoxResult.Yes Then
Close()
End If
End Sub
End Class