我的这个Dim transactionArray As String()()
包含大量数据,两个或多个元素具有相同的值。
当我想搜索数组以找到某些内容时,我有:
For Each tempString As String In transactionArray(tempInt1)
If tempString.Contains(searchText) Then
MessageBox.Show("Found It")
End If
Next
现在我如何获得当前指数?由于我有多个具有相同价值的元素,我猜我不能使用Array.IndexOf
答案 0 :(得分:1)
根据你的尝试
Dim strArray As String() = {"ABC", "BCD", "CDE", "DEF", "EFG", "FGH", _
"GHI"}
Array.IndexOf(strArray, "C")
' not found, returns -1
Array.IndexOf(strArray, "CDE")
' found, returns index
答案 1 :(得分:1)
切换到for循环:
For I = 0 To transactionArray(tempInt1).Count - 1
If transactionArray(tempInt1)(I).Contains(searchText) Then
MessageBox.Show("Found It at index " & I.ToString())
End If
Next