Hey all you VB gurus
I am just curious about using FOR EACH loops with arrays.
I know you can use it with a collections and sinle dimensional arrays. However I need to create a 2-dimensional array where I have to loop through the 2nd column and look for certain values in the rows.
Create the array:
Dim vArray(1 To 3, 1 To 2) As Variant
Dim i As Integer
Dim key As Variant
'Populate the Array
For i = 1 To 3
vArray(i, 1) = i
vArray(i, 2) = "Element No " & CStr(i)
Next
'Now display the values
For Each key In vArray
If key = "Element No 2" Then
MsgBox key
End If
Next
Can I let this loop search only one of the fields rather than all the values?
Rgds
Len
This goes through ALL the values in both fields(columns)
I simply need to go through the 2nd columns
I am just curious about using FOR EACH loops with arrays.
I know you can use it with a collections and sinle dimensional arrays. However I need to create a 2-dimensional array where I have to loop through the 2nd column and look for certain values in the rows.
Create the array:
Dim vArray(1 To 3, 1 To 2) As Variant
Dim i As Integer
Dim key As Variant
'Populate the Array
For i = 1 To 3
vArray(i, 1) = i
vArray(i, 2) = "Element No " & CStr(i)
Next
'Now display the values
For Each key In vArray
If key = "Element No 2" Then
MsgBox key
End If
Next
Can I let this loop search only one of the fields rather than all the values?
Rgds
Len
This goes through ALL the values in both fields(columns)
I simply need to go through the 2nd columns