dibawah ini adalah contoh program sederhana Vb.Net.. tentang penjualan
semoga dapat bermanfaat bagi anda semua gan !!
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kodebarang.Items.Add("RD1200")
kodebarang.Items.Add("RD1201")
kodebarang.Items.Add("KS1200")
kodebarang.Items.Add("KS1201")
BuatTabel()
End Sub
Private Sub kodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
Dim x, y As String
x = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
y = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
Select Case y
Case "200"
namabarang.Text = "Radio"
Case "201"
namabarang.Text = "AC"
Case "200"
namabarang.Text = "Kulkas"
Case "201"
namabarang.Text = "Hand Phone"
End Select
Select Case x
Case "RD"
merk.Text = "LG"
Case "RD"
merk.Text = "LG"
Case "KS"
merk.Text = "Samsung"
Case "KS"
merk.Text = "Samsung"
Case Else
merk.Text = "_"
End Select
Select Case kodebarang.Text
Case "RD1200"
harga.Text = 1000000
Case "RD1201"
harga.Text = 2000000
Case "KS1200"
harga.Text = 2000000
Case "KS1201"
harga.Text = 3000000
Case Else
harga.Text = "_"
End Select
End Sub
Private Sub jumlahbeli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlahbeli.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
totalharga_TextChanged(sender, e)
End If
End Sub
Private Sub totalharga_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles totalharga.TextChanged
totalharga.Text = harga.Text * jumlahbeli.Text
End Sub
Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
End
End Sub
Sub BuatTabel()
LV.Columns.Add("no.pembelian", 80, HorizontalAlignment.Center)
LV.Columns.Add("kode pembelian", 180, HorizontalAlignment.Left)
LV.Columns.Add("nama barang", 180, HorizontalAlignment.Left)
LV.Columns.Add("merk", 180, HorizontalAlignment.Left)
LV.Columns.Add("harga", 180, HorizontalAlignment.Left)
LV.Columns.Add("jumlah beli", 180, HorizontalAlignment.Left)
LV.Columns.Add("total harga", 180, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim Lst As New ListViewItem
Lst.Text = nopembelian.Text
Lst.SubItems.Add(kodebarang.Text)
Lst.SubItems.Add(namabarang.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jumlahbeli.Text)
Lst.SubItems.Add(totalharga.Text)
LV.Items.Add(Lst)
End Sub
Private Sub Btnsimpan_LV_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpan_LV.Click
isitabel()
kodebarang.Text = ""
namabarang.Text = ""
totalharga.Text = ""
jumlahbeli.Text = ""
nopembelian.Text = ""
merk.Text = ""
harga .Text =""
End Sub
Private Sub Btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnbersih.Click
nopembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlahbeli.Text = ""
totalharga.Text = ""
End Sub
Private Sub btnhapus_pilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus_pilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub Btnhapus_semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus_semua.Click
LV.Items.Clear()
End Sub
End Class
Melengkapi tugas dosen:
Mesran M.Kom,S.Kom