Ketikkan Kode Berikut Pada Form Codenya
Option Explicit
Private Konekdb As ADODB.Connection
Private Rs_Kamus As ADODB.Recordset
Private StrKonek, TOMBOL As String
Private SqlSimpan, SqlCari As String
Sub FormBersih()
TxtAsing.Text = ""
TxtIndo.Text = ""
End Sub
Sub BukaDb()
Set Konekdb = New ADODB.Connection
StrKonek = "Provider=Microsoft.Jet.OLEDB.4.0;Persist " _
& "Security Info=False;Data Source=" _
& App.Path + "./Kamus.mdb"
If Konekdb.State = adStateOpen Then
Konekdb.Close
Set Konekdb = New ADODB.Connection
Konekdb.Open StrKonek
Else
Konekdb.Open StrKonek
End If
End Sub
Private Sub Form_Load()
Call BukaDb
End Sub
Private Sub TbKeluar_Click()
Unload Me
End Sub
Private Sub TbSimpan_Click()
If TxtAsing.Text = "" Then
MsgBox "Isi Dulu Bhs Inggrisnya.!", _
vbCritical, "Info"
TxtAsing.SetFocus
ElseIf TxtIndo.Text = "" Then
MsgBox "Isi Dulu Bhs Indonesianya..!", _
vbCritical, "Info"
TxtIndo.SetFocus
Else
SqlSimpan = ""
SqlSimpan = "Insert Into kamus(kata_asing,kata_indo)" _
& " Values('" & TxtAsing.Text _
& "','" & TxtIndo.Text & "')"
Konekdb.Execute SqlSimpan, , adCmdText
MsgBox "Kata baru telah ditambahkan dalam kamus", _
vbInformation, "Info"
Call FormBersih
End If
End Sub
Private Sub TbTambah_Click()
TxtAsing.Text = ""
TxtIndo.Text = ""
End Sub
Private Sub TbTrans_Click()
If TxtIn.Text = "" Then
MsgBox "Kata belum dimasukan..!", _
vbCritical, "Info"
TxtIn.SetFocus
Else
SqlCari = ""
SqlCari = "select kata_indo from kamus " _
& " WHERE kata_asing LIKE '" _
& TxtIn.Text & "'"
Set Rs_Kamus = New ADODB.Recordset
Rs_Kamus.Open SqlCari, Konekdb, _
adOpenDynamic, adLockBatchOptimistic
If Rs_Kamus.EOF And Rs_Kamus.BOF Then
MsgBox "kata yang Anda cari tidak ada..!", _
vbCritical, "Info"
Exit Sub
Else
TxtOut.Text = Rs_Kamus!kata_indo
End If
End If
End Sub
Private Sub TxtIn_Change()
Call FormBersih
End Sub
Semoga Berhasil >>