Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kodebarang.Items.Add("TS001")
kodebarang.Items.Add("TS002")
kodebarang.Items.Add("VG001")
kodebarang.Items.Add("VG002")
Tabel()
nopembelian.Focus()
End Sub
Private Sub kodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
If kodebarang.Text = "TS001" Then
kodebarang.Text = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
namabarang.Text = "Flashdisk 4GB"
kodebarang.Text = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
merk.Text = "Thosiba"
harga.Text = "105000"
ElseIf kodebarang.Text = "TS002" Then
kodebarang.Text = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
namabarang.Text = "Flashdisk 2GB"
kodebarang.Text = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
merk.Text = "Thosiba"
harga.Text = "75000"
ElseIf kodebarang.Text = "VG001" Then
kodebarang.Text = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
namabarang.Text = "Flasdisk 4GB"
kodebarang.Text = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
merk.Text = "V-Gen"
harga.Text = "90000"
Else
kodebarang.Text = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
namabarang.Text = "Flasdisk 2GB"
kodebarang.Text = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
merk.Text = "V-Gen"
harga.Text = "60000"
End If
jumlahpembeli.Focus()
End Sub
Sub Tabel()
Dim isi As New ListViewItem
lv.Columns.Add("No Pembelian", 80, HorizontalAlignment.Left)
lv.Columns.Add("Kode Barang", 90, HorizontalAlignment.Center)
lv.Columns.Add("Nama Barang", 130, HorizontalAlignment.Center)
lv.Columns.Add("Merk Barang", 90, HorizontalAlignment.Left)
lv.Columns.Add("Harga", 80, HorizontalAlignment.Center)
lv.Columns.Add("Jumlah", 50, HorizontalAlignment.Center)
lv.Columns.Add("Total Harga", 100, HorizontalAlignment.Left)
lv.View = View.Details
lv.FullRowSelect = True
lv.GridLines = True
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Close()
End Sub
Private Sub jumlahpembeli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlahpembeli.KeyPress
If Asc(e.KeyChar) = 13 Then
If kodebarang.Text = "" Then
MsgBox("Input No Pembelian Telebih Dahulu", MsgBoxStyle.Exclamation, "Pesan")
Else
totalharga.Text = harga.Text * jumlahpembeli.Text
End If
End If
End Sub
Sub isitable()
Dim x As New ListViewItem
x.Text = nopembelian.Text
x.SubItems.Add(kodebarang.Text)
x.SubItems.Add(namabarang.Text)
x.SubItems.Add(merk.Text)
x.SubItems.Add(harga.Text)
x.SubItems.Add(jumlahpembeli.Text)
x.SubItems.Add(totalharga.Text)
lv.Items.Add(x)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
isitable()
End Sub
Sub bersih()
nopembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlahpembeli.Text = ""
totalharga.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
lv.Items.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
lv.Items.Remove(lv.SelectedItems(0))
End Sub
End Class
Hasil