You will need to do something similar to this.
Dim test As String(,) = New String(,) {{"1", "2", "3"}, {"4", "5", "6"}} Dim cols As Integer = test.GetUpperBound(0) Dim rows As Integer = test.GetUpperBound(1) Dim toFind As String = "4" Dim xIndex As Integer Dim yIndex As Integer For x As Integer = 0 To cols - 1 For y As Integer = 0 To rows - 1 If test(x, y) = toFind Then xIndex = x yIndex = y End If Next Next
On the other hand, many people do not realize that you can use a for each loop on multidimensional arrays.
For Each value As String In test Console.WriteLine(value) Next
This will gradually go through all the sizes of the array.
Hope this helps.
Martyn
source share