Naryan108
asked on
Dynamic Array Not Responding
Hi, I am looping though a string and need to put every instance of the substring into an array to be dealt with later. I don't know how many elements the array will hold, so I start reDim it as part of the loop. However, although my quick tests using reponse.write show that I am getting the right info, I can't seem to put them into the array. That is, when I come to test the array there's nowt in there.
I know there's shorter ways of writing this, but I'm just getting it clear in my head first.
Any help would be a Big help.
I know there's shorter ways of writing this, but I'm just getting it clear in my head first.
Any help would be a Big help.
dim strLen, strPos, varPos, varArray
dim strArray()
strLen = Len(strHTML)
varPos = 1
varArray = 0
Do while varPos < strLen
Redim strArray(varArray)
strPos = instr(varPos, strHTML, "prod", 1)
If strPos = 0 then exit do
strArray(varArray) = mid(strHTML, strPos + 4, 2)
'response.Write(mid(strHTML, strPos + 4, 2))
'response.write("<br />")
varPos = strPos + 6
varArray = varArray + 1
Loop
'response.Write(strArray(1))
For Each product In strArray
response.write(product)
response.write("<br />")
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just to add that prod is repeated several times, e.g.
<p></p><div id="dropContent2"><p><img src="images/l_prod15.jpg"> </p><p>gif titem</p>< br><p><img src="images/L_prod59.jpg"> </p><p>gif titem2</p> </div>
cheers.
<p></p><div id="dropContent2"><p><img src="images/l_prod15.jpg">
cheers.
ASKER
So, split doesn't isolate, capture the good bits and discard the rest, at least not my understanding of it, hence the need for the rest of the routine.
Correct me if I'm wrong...