MESRAN.NETPublic Class Form1
Private Sub btnKode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKode.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(btnKode.Text, 2)
If x = "TS" Then
btnMerk.Text = "TOSHIBA"
ElseIf x = "VG" Then
btnMerk.Text = "V-GEN"
End If
Dim y As String
y = Microsoft.VisualBasic.Mid(btnKode.Text, 3)
If y = "001" Then
btnNama.Text = "FLASHDISK 4GB"
ElseIf y = "002" Then
btnNama.Text = "FLASHDISK 2GB"
End If
Dim z As String
z = Microsoft.VisualBasic.Left(btnKode.Text, 5)
If z = "TS001" Then
btnHarga.Text = "105000"
ElseIf z = "TS002" Then
btnHarga.Text = "75000"
ElseIf z = "VG001" Then
btnHarga.Text = "90000"
ElseIf z = "VG002" Then
btnHarga.Text = "60000"
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
buattabel()
btnKode.Items.Add("TS001")
btnKode.Items.Add("TS002")
btnKode.Items.Add("VG001")
btnKode.Items.Add("VG002")
End Sub
Sub buattabel()
btnLV.Columns.Add("NO.PEMBELIAN", 100, HorizontalAlignment.Center)
btnLV.Columns.Add("KODE BARANG", 100, HorizontalAlignment.Center)
btnLV.Columns.Add("NAMA BARANG", 100, HorizontalAlignment.Center)
btnLV.Columns.Add("MERK", 100, HorizontalAlignment.Center)
btnLV.Columns.Add("HARGA", 100, HorizontalAlignment.Center)
btnLV.Columns.Add("JUMLAH BELI", 100, HorizontalAlignment.Center)
btnLV.Columns.Add("TOTAL HARGA", 100, HorizontalAlignment.Center)
btnLV.View = View.Details
btnLV.GridLines = True
btnLV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = btnNo.Text
Lst.SubItems.Add(btnKode.Text)
Lst.SubItems.Add(btnNama.Text)
Lst.SubItems.Add(btnMerk.Text)
Lst.SubItems.Add(btnHarga.Text)
Lst.SubItems.Add(btnJumlah.Text)
Lst.SubItems.Add(btnTotal.Text)
btnLV.Items.Add(Lst)
End Sub
Private Sub btnJumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles btnJumlah.KeyPress
Dim TOMBOL As Integer = Asc(e.KeyChar)
If TOMBOL = 13 Then
btnsimpankeLV_Click(sender, e)
End If
End Sub
Private Sub btnJumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnJumlah.TextChanged
btnTotal.Text = Val(btnHarga.Text) * Val(btnJumlah.Text)
End Sub
Private Sub btnSimpankeLV_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpankeLV.Click
IsiTabel()
btnNo.Text = " "
btnKode.Text = " "
btnNama.Text = " "
btnMerk.Text = " "
btnHarga.Text = " "
btnJumlah.Text = " "
btnTotal.Text = " "
End Sub
Private Sub btnHapusSemuaData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusSemuaData.Click
btnLV.Items.Clear()
End Sub
Private Sub btnHapusDatayangdipilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusDatayangdipilih.Click
btnLV.Items.Remove(btnLV.SelectedItems(0))
End Sub
Private Sub btnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBersih.Click
btnNo.Text = " "
btnKode.Text = " "
btnNama.Text = " "
btnMerk.Text = " "
btnHarga.Text = " "
btnJumlah.Text = " "
btnTotal.Text = " "
End Sub
Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
End
End Sub
End Class