三个控件 text输入查询的关键字;list放置查询结果;command查询按钮 Dim str As String '定义 读取行变量 If Text1.Text = "" Then Exit Sub List1.Clear '清空文本框 Open "d:\12.txt" For Input As #1 ' 打开文件。 i = 1 Do While Not EOF(1) '逐行读取,在不超出已有行的条件下 Line Input #1, str '读一行给临时变量 If str Like "*" & Text1.Text & "*" Then '比较和关键字象的行数据 List1.AddItem str '赋值TEXT1 k = 1 '标记找到关健行 End If i = i + 1 '下一行 Loop Close #1 If k = 0 Then Text1.Text = "没有相关数据"
Dim a As String = IO.File.ReadAllText(File) dim i as variant static j as variant Dim Lines() As String = Split(a, Chr(10)) For i = 0 to ubound(Lines) if inputbox("关键字") = split(Lines,"-")(1) then j=j+1 dim txt as new textbox txt.text=split(Lines,"-")(0) txt.autosize = true txt.left=2 txt.top = (j-1)*20+2 groupbox1.controls.add(txt) End if Next本回答被提问者采纳