求助,谁能帮我看一下下面的检索部分只能搜到第一个数据,不能真正实现检索功能?
Dim c() As Variant, d() As Variant, m As Integer, n As IntegerPrivate Sub enter_Click()
m = InputBox("请输入录入的数据数量", "输入")
Dim a(m), b(m)
Open App.Path & "\data1.txt" For Append As #1
For i = 1 To m
a(i) = InputBox("请输入名称", "输入")
If a(i) = "" Then a(i) = "未输入"
Print #1, a(i)
Open App.Path & "\data2.txt" For Append As #2
b(i) = InputBox("请输入金额", "输入")
If b(i) = "" Then b(i) = "未输入"
Print #2, b(i)
Close #2
Next i
Close #1
MsgBox "数据录入完成"
End Sub
Private Sub read_Click()
Open App.Path & "\data1.txt" For Input As #1
n = 0
Do While Not EOF(1)
Line Input #1, Data1
n = n + 1
Loop
a = n
If Not EOF(1) Then
For i = 1 To n
Input #1, c(i)
Next i
End If
Open App.Path & "\data2.txt" For Input As #2
If Not EOF(1) Then
For i = 1 To n
Input #2, d(i)
Next i
End If
Close #1
Close #2
MsgBox "数据读取完成,一共" & n & "条数据"
Text1.Enabled = True
Text1.SetFocus
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "请输入要查找的内容"
Text1.SetFocus
End If
For i = 1 To a
If Text1.Text = c(i) Then
MsgBox "姓名:" & c(i) & vbCrLf & "金额:" & d(i)
Else
MsgBox "未查到此人信息"
End If
Next i
End Sub
[此贴子已经被作者于2015-12-29 20:11编辑过]