Minggu, 02 Juni 2013
YUK!! BELAJAR PEMROGRAMAN VISUAL BASIC
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
kodebarang.Items.Add("TS001")
kodebarang.Items.Add("TS002")
kodebarang.Items.Add("VG001")
kodebarang.Items.Add("VG002")
End Sub
Private Sub kodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
Select Case x
Case "TS" : merk.Text = "Toshiba"
Case "VG" : merk.Text = "V-Gen"
End Select
Dim y As String
y = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
Select Case y
Case "001" : namabarang.Text = "Flashdisk 4GB"
Case "002" : namabarang.Text = "Flashdisk 2GB"
End Select
If x = "TS" And y = "001" Then
harga.Text = 105000
ElseIf x = "TS" And y = "002" Then
harga.Text = 75000
ElseIf x = "VG" And y = "001" Then
harga.Text = 90000
ElseIf x = "VG" And y = "002" Then
harga.Text = 60000
End If
End Sub
Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
nopembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlahbeli.Text = ""
totalharga.Text = ""
End Sub
Sub buattabel()
ListView1.Columns.Add("nopembelian", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("kodebarang", 80, HorizontalAlignment.Left)
ListView1.Columns.Add("namabarang", 120, HorizontalAlignment.Left)
ListView1.Columns.Add("merk", 120, HorizontalAlignment.Left)
ListView1.Columns.Add("harga", 120, HorizontalAlignment.Left)
ListView1.Columns.Add("jumlahbeli", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("totalharga", 90, HorizontalAlignment.Left)
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.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)
ListView1.Items.Add(lst)
End Sub
Private Sub Btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpan.Click
isitabel()
End Sub
Private Sub Hapusdipilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapusdipilih.Click
ListView1.Items.Remove(ListView1.SelectedItems(0))
End Sub
Private Sub Hapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapussemua.Click
ListView1.Items.Clear()
End Sub
Private Sub nopembelian_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nopembelian.TextChanged
Select Case nopembelian.Text
Case "001" : namabarang.Text = "Flashdisk 4GB"
harga.Text = 105000
Case "002" : namabarang.Text = "Flashdisk 2GB"
harga.Text = 75000
Case "003" : namabarang.Text = "Flashdisk 4GB"
harga.Text = 90000
Case "004" : namabarang.Text = "Flashdisk 2GB"
harga.Text = 60000
End Select
End Sub
Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
Me.Close()
End Sub
Private Sub jumlahbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlahbeli.TextChanged
totalharga.Text = Val(jumlahbeli.Text) * Val(harga.Text)
End Sub
Private Sub totalharga_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles totalharga.TextChanged
End Sub
Private Sub namabarang_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles namabarang.TextChanged
Select Case namabarang.Text
Case "Flashdisk 4GB" : harga.Text = 105000
Case "Flashdisk 2GB" : harga.Text = 75000
Case "Flashdisk 4GB" : harga.Text = 90000
Case "Flashdisk 2GB" : harga.Text = 60000
End Select
End Sub
End Class
Langganan:
Posting Komentar (Atom)
kreak x ko mul..
BalasHapus