Public Class
Form1
Sub isiTabel()
Dim lst As New ListViewItem
lst.Text =
No.Text
lst.SubItems.Add(Kode.Text)
lst.SubItems.Add(Namabarang.Text)
lst.SubItems.Add(merk.Text)
lst.SubItems.Add(Harga.Text)
lst.SubItems.Add(Jumlah.Text)
lst.SubItems.Add(Total.Text)
LV.Items.Add(lst)
End Sub
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")
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"
ElseIf x = "VG"
Then
merk.Text =
"V-Gen"
End If
x =
Microsoft.VisualBasic.Right(Kode.Text, 3)
If x = "001"
Then
Namabarang.Text = "Flashdisk 4 GB"
ElseIf x = "002"
Then
Namabarang.Text = "Flashdisk 2 Gb"
End If
If Kode.Text = "TS001"
Then
Harga.Text
= 105000
ElseIf Kode.Text = "TS002"
Then
Harga.Text
= 75000
ElseIf Kode.Text = "VG001"
Then
Harga.Text
= "9000"
ElseIf Kode.Text = "VG002"
Then
Harga.Text
= 60000
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
Private Sub
btnkeluar_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnkeluar.Click
End
End Sub
Private Sub
BtnSimpan_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
BtnSimpan.Click
Call isiTabel()
End Sub
Private Sub
BtnHapus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
BtnHapus.Click
LV.Items.Clear()
End Sub
Private Sub
btndipilih_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btndipilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub
btnBersih_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnBersih.Click
Call bersih(Me)
End Sub
Sub Bersih(ByVal F As Form)
Dim x As Object
For Each x In F.Controls
If TypeOf x Is TextBox Then
x.text = ""
If TypeOf x Is ComboBox Then
x.text = ""
Next
End Sub
End Class
Tidak ada komentar:
Posting Komentar