Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kode.Items.Add("1")
kode.Items.Add("2")
kode.Items.Add("3")
lv.Columns.Add("Kode", 50, HorizontalAlignment.Center)
lv.Columns.Add("Nama Produk", 150, HorizontalAlignment.Center)
lv.Columns.Add("Harga", 150, HorizontalAlignment.Left)
lv.Columns.Add("Jumlah", 100, HorizontalAlignment.Center)
lv.Columns.Add("Total", 150, HorizontalAlignment.Left)
lv.View = View.Details
lv.GridLines = True
lv.FullRowSelect = True
End Sub
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Select Case kode.Text
Case "1"
produk.Text = "TV"
harga.Text = 2000000
Case "2"
produk.Text = "DVD"
harga.Text = 650000
Case "3"
produk.Text = "CD-ROOM"
harga.Text = 450000
End Select
End Sub
Private Sub total_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles total.KeyPress
End Sub
Private Sub total_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles total.TextChanged
End Sub
Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
Dim list As New ListViewItem
list.Text = kode.Text
list.SubItems.Add(produk.Text)
list.SubItems.Add(harga.Text)
list.SubItems.Add(jumlah.Text)
list.SubItems.Add(total.Text)
lv.Items.Add(list)
End Sub
Private Sub jumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah.TextChanged
total.Text = Val(harga.Text) * Val(jumlah.Text)
End Sub
Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
kode.Text = ""
produk.Text = ""
harga.Text = ""
jumlah.Text = ""
total.Text = ""
End Sub
Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
End
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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
lv.Items.Clear()
End Sub
End Class
Demikilahlah postingan saya Nama : (Michael Simangunsong) NPM : (14110571)
Selamat Belajar Pemrograman VB NET (Mesran.Net)