Find value in array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In MSAccess Visual basic I have the following code

Dim myArray as variant
Dim intcount as integer

DO UNTIL rst.eof
'I print out data here

'I start to populate my array here, strFactorNumber are "T1.1", "T1.2"
and so on so that at the end the array should contain Myarray=("T1.1",
"T1.2", "T1.3", and so on)

myarray (intcount) = strFactorNumber
intcount = intcount +1
rst.movenext
loop

what I want to be able to do is to search myarray and find if a value
already exists there. If the value is found in the array then I would like
to skip it, if the value is not found then I would like to print it. I'm
pretty new to access and I need Major Help.
 
I found that I can get the value by typing

For i = LBound(myArray) To i = UBound(myArray)
If myArray(i) = "xxxFri" Then
msgbox " array found " & myArray(i)
Else
msgbox " array not found " & myArray(i)
End If
Next

what I'm having problems with is storing the values in an array. I have a
dynamic array myarray (intcount) = strFactorNumber but the value is not put
in to the array. I try to print the value out and it is blank.

the array works if I do type in the value for the array
myarray(intcount) = "T1.1"
but the array doesn't work for
(intcount) = strFactorNumber

Do I need quote around it so the array recognizes the value I'm passing in
or what am I missing.


:
 
Back
Top