Selesaikanlah Kasus Berikut ini :
Berikut jawabannya terlihat seperti dibawah ini :
Tampilan awal program:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
kodebrg.Items.Add("TS001")
kodebrg.Items.Add("TS002")
kodebrg.Items.Add("VG001")
kodebrg.Items.Add("VG002")
End Sub
Sub buattabel()
Lst.Columns.Add("NO.PEMBELIAN", 100, HorizontalAlignment.Center)
Lst.Columns.Add("KODE BARANG", 100, HorizontalAlignment.Center)
Lst.Columns.Add("NAMA BARANG", 100, HorizontalAlignment.Center)
Lst.Columns.Add("MERK", 100, HorizontalAlignment.Center)
Lst.Columns.Add("HARGA", 100, HorizontalAlignment.Center)
Lst.Columns.Add("JUMLAH BELI", 100, HorizontalAlignment.Center)
Lst.Columns.Add("TOTAL HARGA", 100, HorizontalAlignment.Center)
Lst.View = View.Details
Lst.GridLines = True
Lst.GridLines = True
Lst.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst1 As New ListViewItem
Lst1.Text = nopembelian.Text
Lst1.SubItems.Add(kodebrg.Text)
Lst1.SubItems.Add(nmbrg.Text)
Lst1.SubItems.Add(merk.Text)
Lst1.SubItems.Add(hrg.Text)
Lst1.SubItems.Add(jlhbeli.Text)
Lst1.SubItems.Add(Tot.Text)
Lst.Items.Add(Lst1)
End Sub
Private Sub kodebrg_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebrg.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kodebrg.Text, 2)
If x = "TS" Then
merk.Text = "TOSHIBA"
ElseIf x = "VG" Then
merk.Text = "V-GEN"
End If
Dim y As String
y = Microsoft.VisualBasic.Mid(kodebrg.Text, 3)
If y = "001" Then
nmbrg.Text = "FLASHDISK 4GB"
ElseIf y = "002" Then
nmbrg.Text = "FLASHDISK 2GB"
End If
Dim z As String
z = Microsoft.VisualBasic.Left(kodebrg.Text, 5)
If z = "TS001" Then
hrg.Text = "105000"
ElseIf z = "TS002" Then
hrg.Text = "75000"
ElseIf z = "VG001" Then
hrg.Text = "90000"
ElseIf z = "VG002" Then
hrg.Text = "60000"
End If
End Sub
Private Sub Tot_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tot.TextChanged
Tot.Text = Val(hrg.Text) * Val(jlhbeli.Text)
End Sub
Private Sub jlhbeli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jlhbeli.KeyPress
Dim x2 As Integer = Asc(e.KeyChar)
If x2 = 13 Then
Tot.Text = Val(hrg.Text) * Val(jlhbeli.Text)
End If
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
IsiTabel()
nopembelian.Text = " "
kodebrg.Text = " "
nmbrg.Text = " "
merk.Text = " "
hrg.Text = " "
jlhbeli.Text = " "
Tot.Text = " "
End Sub
Private Sub hapusall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusall.Click
Lst.Items.Clear()
End Sub
Private Sub hapuspil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapuspil.Click
Lst.Items.Remove(Lst.SelectedItems(0))
End Sub
Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
nmbrg.Text = " "
kodebrg.Text = " "
nmbrg.Text = " "
merk.Text = " "
hrg.Text = " "
jlhbeli.Text = " "
Tot.Text = " "
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub
End Class
Hasil program :
Demikianlah postingan saya :
Nama : Siti Hajar
NPM : 1111372
0 komentar:
Posting Komentar