MODIFIKASI PROGRAM PENJUALAN
a)
Saat form dijalankan :
semua isian tidak aktif, tombol isidata dan tutup aktif, tombol clear tidak
aktif
b)
Saat ditekan tombol isi
data : kodebarang, jumlahbarang, cara beli, tombol clear, aktif, tombol isidata
tidak aktif
c) Saat ditekan combol clear sama dengan saat
form dijalankan
1. Tambahkan 1 Button untuk program yang kemarin,
Dan edit button tadi
menjadi isi data
Seperti
dibawah ini;
2. Selanjutnya kita isi
listing programnya;
Coding pada form di
tambah seperti dibawah ini;
Dim control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = False
Button3.Enabled = True
Button2.Enabled = True
Next
CmbKodbar.Items.Add("SPT")
CmbKodbar.Items.Add("SND")
CmbKodbar.Items.Add("TST")
CmbKodbar.Items.Add("CLN")
CmbKodbar.Items.Add("TAS")
3. Selanjutnya edit pada button clear sehinga
menjadi seperti dibawah ini;
Dim control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = False
Button3.Enabled = True
Button2.Enabled = True
Next
TxtNambar.Clear()
TxtHarbar.Clear()
TxtJumbar.Clear()
TxtTotHarg.Clear()
TxtDiskon.Clear()
TxtTotBayr.Clear()
Me.RadioButton1.Checked
= False
Me.RadioButton2.Checked
= False
CmbKodbar.Text = ""
4. Yang terakhir isi button ‘’isi data”;
Dim control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = True
Button3.Enabled = False
Next
5. Lalu di Run
Dan
hasilnya seperti berikut ini;semua tidak aktif kecuali Button isi data dan button tutup
6. Klik button Isi data, dan hasilnya seperti
dibawah ini;
Setelah di isi
Dan jika di clear
seperti pada waktu di Run pertama kali
Jika ingiin tahu lebih lanjut download programnya di bawah ini,
Listing Programnya ada di bawah ini;;;
Listing Program
Penjulan Setelah di modifikasi
Public Class
Form1
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim
control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = False
Button3.Enabled = True
Button2.Enabled = True
Next
CmbKodbar.Items.Add("SPT")
CmbKodbar.Items.Add("SND")
CmbKodbar.Items.Add("TST")
CmbKodbar.Items.Add("CLN")
CmbKodbar.Items.Add("TAS")
End Sub
Private Sub
CmbKodbar_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
CmbKodbar.SelectedIndexChanged
Dim
Kodebarang, Namabarang As String
Dim
Harga As Single
Kodebarang = CmbKodbar.Text
Select Case Kodebarang
Case
"SPT"
Namabarang = "Sepatu"
Harga = 100000
Case
"SND"
Namabarang = "Sendal"
Harga = 25000
Case
"TST"
Namabarang = "T-Shirt"
Harga = 30000
Case
"CLN"
Namabarang = "Celana"
Harga = 150000
Case
"TAS"
Namabarang = "TAS"
Harga = 90000
Case Else
Namabarang = "-"
Harga = 0
End Select
TxtNambar.Text = Namabarang
TxtHarbar.Text = Harga
End Sub
Private Sub
TxtJumbar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TxtJumbar.TextChanged
TxtTotHarg.Text = Val(TxtHarbar.Text) *
Val(TxtJumbar.Text)
TxtTotBayr.Text = Val(TxtTotHarg.Text) -
Val(TxtDiskon.Text)
End Sub
Private Sub
RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
RadioButton1.CheckedChanged
TxtDiskon.Text = Val(TxtTotHarg.Text) *
10 / 100
TxtTotBayr.Text = Val(TxtTotHarg.Text)
- Val(TxtDiskon.Text)
End Sub
Private Sub
RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
RadioButton2.CheckedChanged
TxtDiskon.Text = 0
TxtTotBayr.Text = Val(TxtTotHarg.Text)
- Val(TxtDiskon.Text)
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim
control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = False
Button3.Enabled = True
Button2.Enabled = True
Next
TxtNambar.Clear()
TxtHarbar.Clear()
TxtJumbar.Clear()
TxtTotHarg.Clear()
TxtDiskon.Clear()
TxtTotBayr.Clear()
Me.RadioButton1.Checked
= False
Me.RadioButton2.Checked
= False
CmbKodbar.Text = ""
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
If
MsgBox("Apakah anda ingin keluar ?",
vbYesNo + vbQuestion +
vbDefaultButton2, "Keluar") =
vbYes Then
End If
Me.Close()
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim
control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = True
Button3.Enabled = False
Next
End Sub
End Class
0 comments:
Post a Comment