Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net

Selesaikanlah Kasus Berikut ini :  LATIHAN LISTVIEW PERHITUNGAN PENJUALAN BARANG

Berikut jawabannya terlihat seperti dibawah ini :

Public Class Form1
Sub BuatTabel()
LV.Columns.Add(“No Pembelian”, 90, HorizontalAlignment.Center)
LV.Columns.Add(“Kode Barang”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Nama Barang”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Merk”, 72, HorizontalAlignment.Center)
LV.Columns.Add(“Harga”, 70, HorizontalAlignment.Center)
LV.Columns.Add(“Jumlah Beli”, 70, HorizontalAlignment.Center)
LV.Columns.Add(“TotalHarga”, 90, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTable()
Dim Lst As New ListViewItem
Lst.Text = no.Text
Lst.SubItems.Add(kode.Text)
Lst.SubItems.Add(nama.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jmlh.Text)
Lst.SubItems.Add(total.Text)
LV.Items.Add(Lst)
End Sub
Private Sub ComboBox1_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 = “Thosiba”
ElseIf x = “VG” Then
merk.Text = “V-Gen”
End If
x = Microsoft.VisualBasic.Right(kode.Text, 3)
If x = “001” Then
nama.Text = “Flashdisk 4GB”
ElseIf x = “002” Then
nama.Text = “Flashdisk 2GB”
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 = “90000”
ElseIf kode.Text = “VG002” Then
harga.Text = “60000”
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
BuatTabel()
kode.Items.Add(“TS001”)
kode.Items.Add(“TS002”)
kode.Items.Add(“VG001”)
kode.Items.Add(“VG002”)
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub

Private Sub reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reset.Click
no.Text = “”
kode.Text = “”
nama.Text = “”
merk.Text = “”
harga.Text = “”
jmlh.Text = “”
total.Text = “”
End Sub

Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
IsiTable()
no.Text = “”
kode.Text = “”
nama.Text = “”
merk.Text = “”
harga.Text = “”
jmlh.Text = “”
total.Text = “”
End Sub

Private Sub semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles semua.Click
LV.Items.Clear()
End Sub

Private Sub pilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub

Private Sub jmlh_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jmlh.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
total_TextChanged(sender, e)
total.Text = jmlh.Text * harga.Text
End If
End Sub

Private Sub total_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles total.TextChanged

End Sub
End Class
Tampilan Hasil

quiz online

Demikianlah Postingan Saya

Nama : FAZARUL SIDIK

NPM : 1111042

Selamat Belajar PEMROGRAMAN VB NET

Terus Melangkah Maju Dan Ciptakan Inovasi Terbaru

Posted in Education

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s