Open App.Path & "\data.txt" For Random As #1 Len = Len(per) m = LOF(1) \ Len(per) For i = 1 To m Get #1, i, per If per.name = Text1.Text Then Text2.Text = per.num exit for End If Next i Close #1
Open App.Path & "\data.txt" For Random As #1 Len = Len(per)'用指定长度打开随机文件 m = LOF(1) \ Len(per)'计算记录总数 For i = 1 To m Get #1, i, per'读一条记录 If per.name = Text1.Text Then'如果相等 Text2.Text = per.num'取值 exit for'结束循环 End If Next i Close #1 '关闭文件
你问题出在哪? IF 无效,你用 DEBUG.print 把每条记录的 name 显示出来看看错在那.