Refresh Your Mind
Pelajaran VB nih, agak sedikit Susah Gitu... Mungkin contoh programnya ini... CODE MODULE: Public cn As ADODB.ConnectionPublic rs As ADODB.RecordsetSub buka()On Error GoTo cekSet cn = New ADODB.Connectioncn.CursorLocation = adUseClientcn.Open "MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=LP3I" Exit Subcek: MsgBox "Ada Error : " & Err.Description, vbCriticalEnd Sub CODE FORM: Sub kosong()txtkode = ""txtnama = ""txtharga = ""txt_find = ""End SubSub teks(x As Boolean)txtkode.Enabled = xtxtnama.Enabled = xtxtharga.Enabled = xEnd SubSub tampil()x = " select * from barang order by kodebrg"Set rs = New ADODB.Recordsetrs.Open x, cn, adOpenStatic, adLockOptimisticMe.MSHFlexGrid1.ClearSet rs = cn.Execute(x)Set Me.MSHFlexGrid1.DataSource = rsEnd SubSub muncul()On Error Resume NextWith Me.MSHFlexGrid1txtkode = .TextMatrix(.Row, 1)txtnama = .TextMatrix(.Row, 2)harga = .TextMatrix(.Row, 3)End WithEnd SubPrivate Sub cmd_Add_Click()cr = InputBox("Masukkan Kode Barang :")x = " Select * from barang where kodebrg='" & Trim(cr) & "'"Set rs = New ADODB.Recordsetrs.Open x, cn, adOpenStatic, adLockOptimisticIf Not rs.EOF ThenMsgBox "Kode Barang Sudah Digunakan.", vbInformationrs.CloseSet rs = NothingExit SubEnd Ifrs.CloseSet rs = Nothingteks (True)kosongtxtkode = crtxtnama.SetFocusEnd SubPrivate Sub cmd_Close_Click()EndEnd SubPrivate Sub cmd_Del_Click()If MsgBox("Apakah Data Akan Dihapus ?", vbQuestion + vbYesNo) = vbNo Then Exit Subx = ""x = "delete from barang where kodebrg='" & Trim(txtkode) & "'"cn.Execute xMsgBox "Data Sudah Dihapus"tampilEnd SubPrivate Sub cmd_Save_Click()If MsgBox("Apakah Data Sudah Benar ?", vbQuestion + vbYesNo) = vbNo Then Exit SubIf txtkode = "" Or txtnama = "" Or txtharga = "" ThenMsgBox "Tidak Boleh Ada Field Kosong", vbCriticalExit SubEnd Ifx = ""x = "insert into barang values ('"x = x & Trim(txtkode) & "','"x = x & Trim(txtnama) & "',"x = x & Trim(txtharga) & ")"cn.Execute xMsgBox "Data Sudah Disimpan"tampilEnd SubPrivate Sub txt_find_Change()x = " Select * from barang where kodebrg='" & Trim(txt_find) & "'"Set rs = New ADODB.Recordsetrs.Open x, cn, adOpenStatic, adLockOptimisticIf Not rs.EOF Thentxtkode = rs.Fields("kodebrg")txtnama = rs.Fields("namabrg")txtharga = rs.Fields("harga")Exit SubEnd Ifrs.CloseSet rs = NothingEnd SubPrivate Sub Form_Load()Call bukateks (False)tampilEnd SubPrivate Sub MSHFlexGrid1_Click()munculEnd Sub TAMPILAN: Pertama Kedua
Posting Komentar
© Blogger templates The Professional Template by Ourblogtemplates.com 2008
Back to TOP
0 komentar:
Posting Komentar