第1个回答 2008-01-23
'加textbox两个,cmdbutton两个
Dim path As String
Dim words As String '单词加解释
Dim words2 As String '单词加解释
Dim word As String '单词
Dim explain As String '解释
Dim i As Long
Private Sub Command1_Click()
path = IIf(Right(App.path, 1) = "\", App.path, App.path & "\")
Open path & "words.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, words
If words <> "" Then
For i = 1 To Len(words)
If Mid(words, i, 1) = " " Then
word = Mid(words, 1, i - 1)
explain = Mid(words, i)
Open path & "data.mdb" For Append As #1 '写入单词库
Print #1, word & explain & "|" & vbCrLf
Close #1
End If
Next i
End If
Loop
Close #1
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Then MsgBox "请输入要查询的单词": Exit Sub
path = IIf(Right(App.path, 1) = "\", App.path, App.path & "\")
Open path & "data.mdb" For Input As #1
Do While Not EOF(1)
Line Input #1, words2
For i = 1 To Len(words2)
If Mid(words2, i, 1) = "|" Then
If Mid(words2, 1, i - 1) = Text1.Text Then
Text2.Text = Mid(words2, i + 1)
Exit Sub
Else: MsgBox "查找完毕"
End If
End If
Next i
Loop
Close #1
End Sub
Private Sub Form_Load()
Command1.Caption = "导入单词库"
Text1.Text = "请在这里输入您要查找的单词"
Command2.Caption = "查找"
End Sub
'如果觉得好,请加点分