我有一个文本文件,其中包含一些文本行.
我想遍历每一行,直到找到我想要的项目*,然后以标签的形式将其显示在屏幕上.
*我正在通过文本框搜索该项目.
也就是说,在sudo中:
For i = 0 To number of lines in text file
If txtsearch.text = row(i).text Then
lbl1.text = row(i).text
Next i
Run Code Online (Sandbox Code Playgroud) 我有一个像这样的数组
Dim array() As String = {}
Run Code Online (Sandbox Code Playgroud)
和以下代码
For i = 0 To membertable.Rows.Count - 1
If InStr(membertable.Rows(i)("name"), txtSearch.Text, CompareMethod.Text) - 1 _
<> -1 And txtSearch.Text.Length >= 3 Then
found = True
'add the item that matches the criteria to the array here.
End If
Next i
Run Code Online (Sandbox Code Playgroud)
因此,代码循环遍历访问表的行,并且每次在"name"列下找到与我想要将该项添加到数组的条件匹配的值.数据库项始终是一个字符串.