Sabtu, 22 Desember 2012

Contoh : Program input Alat Motor Pada Visual Basic




listingnya :

Dim tambah As Boolean
Sub nonaktif()
Dim ctl As Control
For Each ctl In Form1
If TypeName(ctl) = "textbox" Then
ctl.Locked = True
End If
If TypeName(ctl) = "combobox" Then
ctl.Locked = True
End If
Next
End Sub

Private Sub cmddel_Click()
del = MsgBox("Record ini dihapus ?", 36, "Konfirmasi")
If del = 6 Then
DbPembelian.Recordset.Delete
DbPembelian.Recordset.MoveNext
If DbPembelian.Recordset.EOF Then
DbPembelian.Recordset.MoveLast
End If
End If
End Sub

Private Sub cmdedit_Click()
DbPembelian.Recordset.Edit
aktif
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdfind_Click()
Dim mkode As String * 6
mkode = InputBox("Ketik Kode Barangnya :", "Pencarian Data Barang")
msyarat = "Kode = '" & mkode & " ' "
DbPembelian.Recordset.Index = "Kodebrg"
DbPembelian.Recordset.Seek "=", mkode
If DbPembelian.Recordset.NoMatch Then
MsgBox "Record Kode Barang " + cr + "Tidak ada", 16, "Informasi"
End If
End Sub

Private Sub cmdlast_Click()
DbPembelian.Recordset.MoveLast
MsgBox "Sudah di akhir record", 16, "Imformasi"
End Sub
Private Sub cmdnew_Click()
tambah = True
DbPembelian.Recordset.AddNew
kosong
aktif
End Sub

Private Sub cmdnext_Click()
DbPembelian.Recordset.MoveNext
If DbPembelian.Recordset.EOF Then
DbPembelian.Recordset.MoveLast
MsgBox "Sudah di akhir record", 16, "Informasi"
End If
End Sub

Private Sub cmdprevious_Click()
DbPembelian.Recordset.MovePrevious
If DbPembelian.Recordset.EOF Then
DbPembelian.Recordset.MoveLast
MsgBox "Sudah di Awal record", 16, "Informasi"
End If
End Sub

Private Sub cmdsave_Click()
If tambah = True Then
DbPembelian.Recordset.Update
Else
DbPembelian.Recordset.Update
End If
nonaktif
End Sub

Private Sub cmdtop_Click()
DbPembelian.Recordset.MoveFirst
MsgBox "Sudah di awal record", 16, "Informasi"
End Sub

Private Sub cmdundo_Click()
DbPembelian.Recordset.CancelUpdate
DbPembelian.Recordset.MoveLast
nonaktif
End Sub

Private Sub Command1_Click()
Text2.Text = txtharga * Text1.Text
End Sub

Private Sub Form_Load()
nonaktif
tambah = False
End Sub

Sub kosong()
Dim ctl As Control
For Each ctl In Form1
If TypeName(ctl) = "textbox" Then
ctl.Text = ""
End If
If TypeName(ctl) = "combobox" Then
ctl.Text = ""
End If
Next
End Sub
Sub aktif()
Dim ctl As Control
For Each ctl In Form1
If TypeName(ctl) = "textbox" Then
ctl.Locked = False
End If
If TypeName(ctl) = "combobox" Then
ctl.Locked = False
End If
Next
End Sub








Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes