Berikut Jawaban :
Public Class Form2
Private Sub BtnKeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnKeluar.Click
End
End Sub
Private Sub Btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnhapus.Click
Jmllembar.Text = ""
Harga.Text = ""
Totlharga.Text = ""
Discount.Text = ""
Pembayaran.Text = ""
End Sub
Private Sub BtnProses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnProses.Click
If
Jmllembar.Text >= "200" Then
Harga.Text = "90"
Else
Harga.Text = 999
End If
Totlharga.Text = Jmllembar.Text *
Harga.Text
If
Totlharga.Text >= 500000 Then
Discount.Text = Totlharga.Text *
0.15
Else
Discount.Text = 0
End If
Pembayaran.Text = Totlharga.Text -
Discount.Text
End Sub
Private Sub Form2_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class
Quis No 1
Hasil :
Public Class Form3
Private Sub Form3_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Kdbarang.Items.Add("TS001")
Kdbarang.Items.Add("TS002")
Kdbarang.Items.Add("VG001")
Kdbarang.Items.Add("VG002")
buattabel()
End Sub
Sub
buattabel()
List.Columns.Add("No Pembelian", 80,
HorizontalAlignment.Center)
List.Columns.Add("Kode Barang", 80,
HorizontalAlignment.Left)
List.Columns.Add("Nama Barang", 80,
HorizontalAlignment.Right)
List.Columns.Add("Merek", 80, HorizontalAlignment.Center)
List.Columns.Add("Harga", 80, HorizontalAlignment.Center)
List.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Center)
List.Columns.Add("Total Harga", 80,
HorizontalAlignment.Center)
List.View = View.Details
List.GridLines = True
List.FullRowSelect = True
End Sub
Sub
isitabel()
Dim Lst
As New
ListViewItem
Lst.Text = Nopem.Text
Lst.SubItems.Add(Kdbarang.Text)
Lst.SubItems.Add(Nmbarang.Text)
Lst.SubItems.Add(Merek.Text)
Lst.SubItems.Add(Harga.Text)
Lst.SubItems.Add(Jmlh.Text)
Lst.SubItems.Add(Total.Text)
List.Items.Add(Lst)
End Sub
Private Sub Btnsimpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnsimpan.Click
isitabel()
Nopem.Text = ""
Kdbarang.Text = ""
Nmbarang.Text = ""
Merek.Text = ""
Harga.Text = ""
Jmlh.Text = ""
Total.Text = ""
End Sub
Private Sub Bthhapussemua_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Bthhapussemua.Click
List.Items.Clear()
End Sub
Private Sub Btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnhapus.Click
List.Items.Remove(List.SelectedItems(0))
End Sub
Private Sub BtnKeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnKeluar.Click
End
End Sub
Private Sub Btnbersih_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnbersih.Click
Nopem.Text = ""
Kdbarang.Text = ""
Nmbarang.Text = ""
Merek.Text = ""
Harga.Text = ""
Jmlh.Text = ""
Total.Text = ""
End Sub
Private Sub Kdbarang_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles Kdbarang.SelectedIndexChanged
Dim x As String
x =
Microsoft.VisualBasic.Left(Kdbarang.Text, 2)
Select Case x
Case
"TS" : Merek.Text = ("Toshiba")
Case
"VG" : Merek.Text = ("V-Gen")
End Select
Dim y As String
y =
Microsoft.VisualBasic.Right(Kdbarang.Text, 3)
Select Case y
Case
"001" : Nmbarang.Text = ("Flashdisk 4GB")
Case
"002" : Nmbarang.Text = ("Flashdisk 2GB")
End Select
Dim z As String
z
= Microsoft.VisualBasic.Left(Kdbarang.Text, 5)
Select Case z
Case
"TS001" : Harga.Text = ("105000")
Case
"TS002" : Harga.Text = ("75000")
Case
"VG001" : Harga.Text = ("90000")
Case
"VG002" : Harga.Text = ("60000")
End Select
End Sub
Private Sub Total_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Total.TextChanged
End Sub
Private Sub Jmlh_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
Jmlh.KeyPress
If
e.KeyChar = Chr(13) Then
Total.Text = Harga.Text * Jmlh.Text
End If
End Sub
Private Sub Jmlh_TextChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles Jmlh.TextChanged
End Sub
Private Sub Nopem_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Nopem.TextChanged
End Sub
End Class
Selamat Pemrograman VB NET
0 komentar:
Posting Komentar