I am using vbscript to load 3 arrays with values from a file. This part works fine as I can watch it load each element. Code is below.
Sub LoadCityIDArray(strCity, strCityName, strCitySiteID, intA)
redim preserve arrCity(intA)
redim preserve arrCityName(intA)
redim preserve arrCItySiteID(intA)
arrCity(intA) = strCity
arrCityName(intA) = strCityName
arrCitySiteID(intA) = strCitySiteID
End Sub
VBEND
When I try to use VBEval to attempt to find a matching entry in the
array I either get a "subscript out of range" error or the first element.
Here is my code.
Let>o=0
Let>q=0
Repeat>o
let>o=o+1
VBEval>ArrCity(0,q),myCity
MessageModal>myCity
MessageModal>city
If>myCity=city
MessageModal>Found it!
Endif
Let>intA=intA+1
Let>q=q+1
Until>o,25
I have searched the forum and tips and tricks on how to iterate through an array using VBEval but I seem to be missing something. I need the value in "city" to match to one of the array elements before continuing.
Anyone have any ideas what I am doing wrong.
Thanks
VBScript Array Element problem
Moderators: Dorian (MJT support), JRL
Is ArrCity a global array? Post full code. If it is local only then that won't work. Also you'd need to do this:
VBEval>ArrCity(0,%q%),myCity
Since q is a MacroScript variable. Without the % it is seen as literally q which would cause an error unless q was also defined as a VBScript variable.
VBEval>ArrCity(0,%q%),myCity
Since q is a MacroScript variable. Without the % it is seen as literally q which would cause an error unless q was also defined as a VBScript variable.
MJT Net Support
[email protected]
[email protected]