用VB数据库做简易英语词典

来源:百度知道 编辑:UC知道 时间:2024/09/26 20:27:54
界面是上面是两个文本框,用来检索,对应的下面是两个列表框,分别放单词和中文意思。这个代码的缺点是要输入完整的单词才能跳到列表框里的相应单词,没输完的时候他就乱跳,哪位高手给我指点下~~
Private Sub Form_Load()
Dim conn As New ADODB.Connection
conn.Provider = "Microsoft.Jet.OleDB.4.0"
conn.Open App.Path & "\双向词典.mdb"

Set rs = conn.Execute("词典")
conn.Cancel
Do Until rs.EOF
List1.AddItem rs("英语")
List2.AddItem rs("汉语")
rs.MoveNext
Loop

conn.Close
End Sub

Private Sub List1_Click()
List2.ListIndex = List1.ListIndex
End Sub

Private Sub List2_Click()
List1.ListIndex = List2.ListIndex
End Sub

Private Sub Text1_Change()
Dim i As Integer
Dim intSelIndex As Integer
intSelIndex = -1

If Text1.Text <> "" Then
For i = 0 To Me.List1.ListCount - 1
If InStr(Me.List

其实这个很简单呀,就是SQL语句的问题。
private sub text2_change()
dim rs as adodb.recordset
dim str as string
dim sql as string
str=text2.text
sql="select 单词,音标,词意,注释,... from 词汇表 where 单词 like '"&str&"%' order by 单词"
rs.open sql,conn,1,3
if rs.recordcount>0 then
list1.clear
rs.movefirst
for i=1 to rs.recordcount
list1.additem rs.fields("单词"),i
next i
end if
end sub

我有个示例比较好
你要不