Latihan Step by Step Visual Basic

Download Latihan Step by Step Visual Basic

Post on 18-Nov-2014

105 views

Category:

Documents

3 download

DESCRIPTION

Dengan Belajar Langkah demi Langkah, mulai membuat From kemudian pengaturan Propertiesnya seterunya membuat listing.....SELAMAT BELAJAR

TRANSCRIPT

<p>Jawaban Quiz Tipe A</p> <p>Objek-objek yang terkait : Objeck PropertiesForm1 Label1 Data1 Caption Caption Name Caption Database Name Recordset Type Record Source Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Name DataSource DataField Text Name DataSource DataField Text Name DataSource DataField Text Name DataSource DataField Text Name DataSource DataField Text</p> <p>NilaiAlga Musa Motor Alga Musa Motor Motor Data Motor Cari Difolder Masing2 0-Table Tbl_Motor Pilihan Motor Yang Tersedia Menu Pilihan Combo1 Data Transaksi Jenis Motor Harga Motor Jumlah Beli Bayar Potongan Total Bayar Text1 Motor Sesuaikan dengan fieldnya masing2 Text 2 Motor Sesuaikan dengan fieldnya masing2 Text 3 Motor Sesuaikan dengan fieldnya masing2 Text4 Motor Sesuaikan dengan fieldnya masing2 Text5 Motor Sesuaikan dengan fieldnya masing2 </p> <p>Frame1 label ComboBox1 Frame4 Label2 Label3 Label4 Label5 Label6 Label7 Text1</p> <p>Text2</p> <p>Text3</p> <p>Text4</p> <p>Text5</p> <p>Text6</p> <p>CommandButton1 CommandButton2 CommandButton3 CommandButton4 CommandButton5 Dbgrid1</p> <p>Name DataSource DataField Text Name Caption Name Caption Name Caption Name Caption Name Caption Caption DataSource</p> <p>Text6 Motor Sesuaikan dengan fieldnya masing2 Cmdtambah TAMBAH Cmdsimpan SIMPAN Cmdbatal BATAL Cmdhitung HITUNG Cmdkeluar KELUAR DATA TRANSAKSI Motor</p> <p>Listing Programnya: Private Sub cmdbatal_Click() MOTOR.Recordset.CancelUpdate MOTOR.Recordset.MoveLast End Sub Private Sub cmdhapus_Click() del = MsgBox("Record Mo Dihapus?", 36, "Konfirmasi") If del = 6 Then MOTOR.Recordset.Delete MOTOR.Recordset.MoveLast If MOTOR.Recordset.EOF Then MOTOR.Recordset.MoveLast End If End If End Sub Private Sub cmdhitung_Click() txtbayar.Text = Val(txtharga.Text) * Val(txtjumlah.Text) If txtjumlah &gt; 5 Then txtpotong.Text = 2 / 100 * Val(txtbayar.Text) txttotal.Text = Val(txtbayar.Text) - Val(txtpotong.Text) Else txtpotong.Text = 0 txttotal = Val(txtbayar.Text) - Val(txtpotong.Text) End If End Sub Private Sub cmdkeluar_Click() psn = MsgBox("Anda Yakin Ingin Keluar", 32 + 4, "Informasi") If psn = vbYes Then MsgBox "Makasih Yach.........", 32, "informasi" End Else If psn = vbNo Then MsgBox "Lho.....kok enggak jadi toh", 32, "Informasi" End If End If End Sub Private Sub cmdsimpan_Click() If tambah = True Then MOTOR.Recordset.Update Else MOTOR.Recordset.Update End If End Sub</p> <p>Private Sub cmdtambah_Click() tambah = True MOTOR.Recordset.AddNew txtjenis.SetFocus End Sub Private Sub Combo1_CLICK() If Combo1 = "SPR" Then txtjenis = "SUPRA" txtharga = 8000000 ElseIf Combo1 = "KRM" Then txtjenis = "KARISMA" txtharga = 8500000 ElseIf Combo1 = "LGD" Then txtjenis = "LAGENDA" txtharga = 8560000 ElseIf Combo1 = "WIN" Then txtjenis = "HONDA WIN" txtharga = 7500000 ElseIf Combo1 = "SHM" Then txtjenis = "SMESH" txtharga = 6500000 ElseIf Combo1 = "SGN" Then txtjenis = "SHOGUN" txtharga = 7800000 ElseIf Combo1 = "STR" Then txtjenis = "SATRIA" txtharga = 13000000 ElseIf Combo1 = "FGR" Then txtjenis = "FEGA R" txtharga = 12000000 ElseIf Combo1 = "JPR" Then txtjenis = "JUPITER" txtharga = 10000000 ElseIf Combo1 = "RXK" Then txtjenis = "RX KING" txtharga = 15000000 End If End Sub Private Sub Form_Load() tambah = False Combo1.AddItem "SPR" Combo1.AddItem "KRM" Combo1.AddItem "LGD" Combo1.AddItem "WIN" Combo1.AddItem "SHM" Combo1.AddItem "SGN" Combo1.AddItem "STR" Combo1.AddItem "FGR" Combo1.AddItem "JPR" Combo1.AddItem "RXK" End Sub Private Sub txtjumlah_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdhitung.SetFocus End If End Sub</p> <p>Jawaban Quiz Tipe B</p> <p>Objek-objek yang terkait : Objeck PropertiesForm1 Label1 Data1 Caption Caption Name Caption Database Name Recordset Type Record Source Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Name DataSource DataField Text Name DataSource DataField Text Name DataSource DataField Text Name DataSource DataField Text Name DataSource DataField Text</p> <p>NilaiAlga Musa Motor Alga Musa Motor Motor Data Motor Cari Difolder Masing2 0-Table Tbl_Motor Pilihan Motor Yang Tersedia Menu Pilihan List1 Data Transaksi Jenis Motor Harga Motor Jumlah Beli Bayar Potongan Total Bayar Text1 Motor Sesuaikan dengan fieldnya masing2 Text 2 Motor Sesuaikan dengan fieldnya masing2 Text 3 Motor Sesuaikan dengan fieldnya masing2 Text4 Motor Sesuaikan dengan fieldnya masing2 Text5 Motor Sesuaikan dengan fieldnya masing2 </p> <p>Frame1 label List1 Frame4 Label2 Label3 Label4 Label5 Label6 Label7 Text1</p> <p>Text2</p> <p>Text3</p> <p>Text4</p> <p>Text5</p> <p>Text6</p> <p>CommandButton1 CommandButton2 CommandButton3 CommandButton4 CommandButton5 Dbgrid1</p> <p>Name DataSource DataField Text Name Caption Name Caption Name Caption Name Caption Name Caption Caption DataSource</p> <p>Text6 Motor Sesuaikan dengan fieldnya masing2 Cmdtambah TAMBAH Cmdsimpan SIMPAN Cmdbatal BATAL Cmdhitung HITUNG Cmdkeluar KELUAR DATA TRANSAKSI Motor</p> <p>Listing Programnya: Private Sub Form_Load() tambah = False List1.AddItem "SPR" List1.AddItem "KRM" List1.AddItem "LGD" List1.AddItem "WIN" List1.AddItem "SHM" List1.AddItem "SGN" List1.AddItem "STR" List1.AddItem "FGR" List1.AddItem "JPR" List1.AddItem "RXK" End Sub Private Sub List1_Click() If List1 = "SPR" Then txtjenis = "SUPRA" txtharga = 8000000 ElseIf List1 = "KRM" Then txtjenis = "KARISMA" txtharga = 8500000 ElseIf List1 = "LGD" Then txtjenis = "LAGENDA" txtharga = 8560000 ElseIf List1 = "WIN" Then txtjenis = "HONDA WIN" txtharga = 7500000 ElseIf List1 = "SHM" Then txtjenis = "SMESH" txtharga = 6500000 ElseIf List1 = "SGN" Then txtjenis = "SHOGUN" txtharga = 7800000 ElseIf List1 = "STR" Then txtjenis = "SATRIA" txtharga = 13000000 ElseIf List1 = "FGR" Then txtjenis = "FEGA R" txtharga = 12000000 ElseIf List1 = "JPR" Then txtjenis = "JUPITER" txtharga = 10000000 ElseIf List1 = "RXK" Then txtjenis = "RX KING" txtharga = 15000000 End If End Sub</p> <p>Private Sub cmdbatal_Click() motor.Recordset.CancelUpdate motor.Recordset.MoveLast End Sub Private Sub cmdhapus_Click() del = MsgBox("Record Mo Dihapus?", 36, "Konfirmasi") If del = 6 Then motor.Recordset.Delete motor.Recordset.MoveLast If motor.Recordset.EOF Then motor.Recordset.MoveLast End If End If End Sub Private Sub cmdhitung_Click() txtbayar.Text = Val(txtharga.Text) * Val(txtjumlah.Text) If txtjumlah &gt; 5 Then txtpotong.Text = 2 / 100 * Val(txtbayar.Text) txttotal.Text = Val(txtbayar.Text) - Val(txtpotong.Text) Else txtpotong.Text = 0 txttotal = Val(txtbayar.Text) - Val(txtpotong.Text) End If End Sub Private Sub cmdkeluar_Click() psn = MsgBox("Anda Yakin Ingin Keluar", 32 + 4, "Informasi") If psn = vbYes Then MsgBox "Makasih Yach.........", 32, "informasi" End Else If psn = vbNo Then MsgBox "Lho.....kok enggak jadi toh", 32, "Informasi" End If End If End Sub Private Sub cmdsimpan_Click() If tambah = True Then motor.Recordset.Update Else motor.Recordset.Update End If End Sub Private Sub cmdtambah_Click() tambah = True motor.Recordset.AddNew txtjenis.SetFocus End Sub Private Sub txtjumlah_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdhitung.SetFocus End If End Sub</p>