Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RancangTabel()
kode.Items.Add("TS001")
kode.Items.Add("TS002")
kode.Items.Add("VG001")
kode.Items.Add("VG002")
End Sub
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Dim x As String
x = Mid(kode.Text, 1, 2)
Select Case x
Case "TS"
merek.Text = "TOSIBAH"
Case "VG"
merek.Text = "V-GEN"
End Select
x = Mid(kode.Text, 3, 5)
Select Case x
Case "001"
nama.Text = "Flasdisk4GB"
Case "002"
nama.Text = "Flasdisk2GB"
End Select
If kode.Text = "TS001" Then
harga.Text = "105000"
ElseIf kode.Text = "TS002" Then
harga.Text = "75000"
ElseIf kode.Text = "VG001" Then
harga.Text = "90000"
ElseIf kode.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub
Private Sub jbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jbeli.TextChanged
tharga.Text = Val(harga.Text) * Val(jbeli.Text)
End Sub
Sub RancangTabel()
lv.Columns.Add("No Pembeli", 50, HorizontalAlignment.Left)
lv.Columns.Add("Kode Barang", 100, HorizontalAlignment.Left)
lv.Columns.Add("Nama", 120, HorizontalAlignment.Left)
lv.Columns.Add("Merek", 120, HorizontalAlignment.Center)
lv.Columns.Add("Harga", 80, HorizontalAlignment.Center)
lv.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
lv.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
lv.FullRowSelect = True
lv.GridLines = True
lv.View = View.Details
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
Call MasukTabel()
no.Text = ""
kode.Text = ""
nama.Text = ""
merek.Text = ""
harga.Text = ""
jbeli.Text = ""
tharga.Text = ""
End Sub
Sub MasukTabel()
Dim a As New ListViewItem
a.Text = no.Text
a.SubItems.Add(kode.Text)
a.SubItems.Add(nama.Text)
a.SubItems.Add(merek.Text)
a.SubItems.Add(harga.Text)
a.SubItems.Add(jbeli.Text)
a.SubItems.Add(tharga.Text)
lv.Items.Add(a)
End Sub
Sub g()
no.Text = ""
kode.Text = ""
nama.Text = ""
merek.Text = ""
harga.Text = ""
jbeli.Text = ""
tharga.Text = ""
End Sub
Private Sub hapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusdata.Click
lv.Items.Clear()
End Sub
Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
Call g()
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub
Private Sub hdpilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hdpilih.Click
If lv.SelectedItems.Count <> 0 Then
lv.SelectedItems(0).Remove()
Else
MsgBox("Plih dr tabel nya Bro !By ELEKSON", MsgBoxStyle.OkOnly, "Informasi")
End If
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RancangTabel()
kode.Items.Add("TS001")
kode.Items.Add("TS002")
kode.Items.Add("VG001")
kode.Items.Add("VG002")
End Sub
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Dim x As String
x = Mid(kode.Text, 1, 2)
Select Case x
Case "TS"
merek.Text = "TOSIBAH"
Case "VG"
merek.Text = "V-GEN"
End Select
x = Mid(kode.Text, 3, 5)
Select Case x
Case "001"
nama.Text = "Flasdisk4GB"
Case "002"
nama.Text = "Flasdisk2GB"
End Select
If kode.Text = "TS001" Then
harga.Text = "105000"
ElseIf kode.Text = "TS002" Then
harga.Text = "75000"
ElseIf kode.Text = "VG001" Then
harga.Text = "90000"
ElseIf kode.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub
Private Sub jbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jbeli.TextChanged
tharga.Text = Val(harga.Text) * Val(jbeli.Text)
End Sub
Sub RancangTabel()
lv.Columns.Add("No Pembeli", 50, HorizontalAlignment.Left)
lv.Columns.Add("Kode Barang", 100, HorizontalAlignment.Left)
lv.Columns.Add("Nama", 120, HorizontalAlignment.Left)
lv.Columns.Add("Merek", 120, HorizontalAlignment.Center)
lv.Columns.Add("Harga", 80, HorizontalAlignment.Center)
lv.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
lv.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
lv.FullRowSelect = True
lv.GridLines = True
lv.View = View.Details
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
Call MasukTabel()
no.Text = ""
kode.Text = ""
nama.Text = ""
merek.Text = ""
harga.Text = ""
jbeli.Text = ""
tharga.Text = ""
End Sub
Sub MasukTabel()
Dim a As New ListViewItem
a.Text = no.Text
a.SubItems.Add(kode.Text)
a.SubItems.Add(nama.Text)
a.SubItems.Add(merek.Text)
a.SubItems.Add(harga.Text)
a.SubItems.Add(jbeli.Text)
a.SubItems.Add(tharga.Text)
lv.Items.Add(a)
End Sub
Sub g()
no.Text = ""
kode.Text = ""
nama.Text = ""
merek.Text = ""
harga.Text = ""
jbeli.Text = ""
tharga.Text = ""
End Sub
Private Sub hapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusdata.Click
lv.Items.Clear()
End Sub
Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
Call g()
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub
Private Sub hdpilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hdpilih.Click
If lv.SelectedItems.Count <> 0 Then
lv.SelectedItems(0).Remove()
Else
MsgBox("Plih dr tabel nya Bro !By ELEKSON", MsgBoxStyle.OkOnly, "Informasi")
End If
End Sub
End Class