Minggu, 29 Januari 2012
Jawaban Soal No 2 (Ihsan Dedy Boy Marpaung)
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BUATTABEL()
kode.Items.Add("TS001")
kode.Items.Add("TS002")
kode.Items.Add("VG001")
kode.Items.Add("VG002")
End Sub
Sub ihsan()
Dim x As String
x = Microsoft.VisualBasic.Left(kode.Text, 2)
If x = "TS" Then
merk.Text = "THOSIBA"
Else
merk.Text = "V-GEN"
End If
x = Microsoft.VisualBasic.Right(kode.Text, 3)
If x = "001" Then
nama.Text = "FLASHDISK 4GB"
Else
nama.Text = "FLASHDISK 2GB"
End If
End Sub
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
ihsan()
If kode.Text = "TS001" Then
harga.Text = "105000"
ElseIf kode.Text = "TS002" Then
harga.Text = "75000"
ElseIf kode.Text = "VG001" Then
harga.Text = "90000"
Else
harga.Text = "60000"
End If
End Sub
Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
Dim TOMBOL As Integer = Asc(e.KeyChar)
If TOMBOL = 13 Then
total.Text = harga.Text * jumlah.Text
End If
End Sub
Sub BUATTABEL()
LV.Columns.Add("NO PEMBELI", 80, HorizontalAlignment.Center)
LV.Columns.Add("KODE BARANG", 80, HorizontalAlignment.Left)
LV.Columns.Add("NAMA BARANG", 100, HorizontalAlignment.Left)
LV.Columns.Add("MEREK", 80, HorizontalAlignment.Left)
LV.Columns.Add("HARGA", 80, HorizontalAlignment.Left)
LV.Columns.Add("JUMLAH BELI", 80, HorizontalAlignment.Left)
LV.Columns.Add("TOTAL HARGA", 80, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub ISITABEL()
Dim LST As New ListViewItem
LST.Text = nomor.Text
LST.SubItems.Add(kode.Text)
LST.SubItems.Add(nama.Text)
LST.SubItems.Add(merk.Text)
LST.SubItems.Add(harga.Text)
LST.SubItems.Add(jumlah.Text)
LST.SubItems.Add(total.Text)
LV.Items.Add(LST)
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
ISITABEL()
End Sub
Private Sub Bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bersih.Click
nomor.Text = ""
kode.Text = ""
nama.Text = ""
merk.Text = ""
harga.Text = ""
jumlah.Text = ""
total.Text = ""
End Sub
Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
End
End Sub
Private Sub hapusn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusn.Click
LV.Items.Clear()
End Sub
Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
End Class
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar