Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Kode.Items.Add("TS001")
Kode.Items.Add("TS002")
Kode.Items.Add("VG001")
Kode.Items.Add("VG002")
rancangan_table()
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)
If x = "TS" Then
Merk.Text = "Toshiba"
x = Microsoft.VisualBasic.Right(Kode.Text, 3)
If x = "001" Then
Nama.Text = "Flashdisk 4GB"
Harga.Text = 105000
ElseIf x = "002" Then
Nama.Text = "Flashdisk 2GB"
Harga.Text = 750000
End If
ElseIf x = "VG" Then
Merk.Text = "V-Gen"
x = Microsoft.VisualBasic.Right(Kode.Text, 3)
If x = "001" Then
Nama.Text = "Flashdisk 4GB"
Harga.Text = 900000
ElseIf x = "002" Then
Nama.Text = "Flashdisk 2GB"
Harga.Text = 60000
End If
End If
End Sub
Private Sub Jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah.KeyPress
If Asc(e.KeyChar) = 13 Then
Total.Text = Harga.Text * Jumlah.Text
End If
End Sub
Sub rancangan_table()
With lv
.Columns.Add("No Pembelian", 100, HorizontalAlignment.Center)
.Columns.Add("Kode barang", 100, HorizontalAlignment.Left)
.Columns.Add("Nama Barang", 100, HorizontalAlignment.Left)
.Columns.Add("Merk", 100, HorizontalAlignment.Left)
.Columns.Add("harga", 100, HorizontalAlignment.Left)
.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Left)
.Columns.Add("Total harga", 100, HorizontalAlignment.Left)
.View = View.Details
.GridLines = True
.FullRowSelect = True
End With
End Sub
Sub isi_table()
Dim lst As New ListViewItem
With lst
.Text = No.Text
.SubItems.Add(Kode.Text)
.SubItems.Add(Nama.Text)
.SubItems.Add(Merk.Text)
.SubItems.Add(Harga.Text)
.SubItems.Add(Jumlah.Text)
.SubItems.Add(Total.Text)
lv.Items.Add(lst)
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
isi_table()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
lv.Items.Remove(lv.SelectedItems(0))
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
lv.Items.Clear()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
No.Text = ""
Kode.Text = ""
Nama.Text = ""
Merk.Text = ""
Harga.Text = ""
Jumlah.Text = ""
Total.Text = ""
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Close()
End Sub
End Class