dengan IF THEN ,mari kita lihat contoh kasusnya dalam pembelian album CherryBelle .
Buat Designya Dulu yuk ...
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Kode.Items.Add("CB001")
Kode.Items.Add("NH002")
Kode.Items.Add("SM003")
Kode.Items.Add("AF004")
Kode.Items.Add("BCL005")
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(Kode.Text, 2)
Select Case x
Case "CB"
NamaArtis.Text = "CherryBelle"
Case "NH"
NamaArtis.Text = "NOAH"
Case "SM"
NamaArtis.Text = "SMASH"
Case "AF"
NamaArtis.Text = "AFGAN"
Case "BC"
NamaArtis.Text = "Bunga Citra Lestari"
End Select
Dim j As String
j = Microsoft.VisualBasic.Right(Kode.Text, 3)
Select Case j
Case "001"
Album.Text = "Diam Diam Suka"
Case "002"
Album.Text = "Seperti Seharusnya"
Case "003"
Album.Text = "Step Forward"
Case "004"
Album.Text = "Confession"
Case "005"
Album.Text = "Cinta Pertama"
End Select
Select Case x & j
Case "CB" & "001"
Harga.Text = 300000
Discount.Text = 0.05 * Harga.Text
Case "NH" & "002"
Harga.Text = 100000
Discount.Text = 0.02 * Harga.Text
Case "SM" & "003"
Harga.Text = 200000
Discount.Text = 0.04 * Harga.Text
Case "AF" & "004"
Harga.Text = 150000
Discount.Text = 0.03 * Harga.Text
Case "BC" & "005"
Harga.Text = 150000
Discount.Text = 0.01 * Harga.Text
End Select
End Sub
Private Sub Hitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hitung.Click
Total.Text = Val(Harga.Text - Discount.Text)
End Sub
Private Sub Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click
Kode.Text = ""
NamaArtis.Text = ""
Album.Text = ""
Harga.Text = ""
Jumlah.Text = ""
Discount.Text = ""
Total.Text = ""
End Sub
Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
End
End Sub
End Class
Catatan: Name dari Textbox maupun Combobox sesuai dengan yang di Coding atau diralat sesuai keingin kalian juga tidak apa apa ...
0 comments:
Post a Comment