I’m trying to assign a value to a series of variables inside a FOR EACH loop, but keep getting a “Type mismatch” error.
personOrder = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" 'order items displayed onscreen
personArray = split(personOrder, ",")
For each i in personArray
imageArray(i) = objContentXML.selectSingleNode("/page/profile" & i & "/image").text
Next
Note: I’ve made the var personOrder a list because in the future items might change order.
I think there’s a problem with assigning array values in a FOR EACH loop. Annoyingly it works fine in a FOR loop, but I’m trying to future proof my code.
Apologies if this question is too stupid. I’m returning after 9 months of nappies and burping to the world of code (less nappies, more burping).
On which statement do you get this error? I can execute the following code without any error messages:
You must create an array first and declare the number of items you want to put in it (use redim to change the dimensions).
I replaced your objectContentXML with a simple statement, for testing purposes.