Link to home
Start Free TrialLog in
Avatar of Naryan108
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.
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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dimitris
Dimitris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Naryan108
Naryan108

ASKER

Hi, thanks, but I don't think it will quite do the job.  Let me explain what exactly I'm after...Within the string is the word 'prod' on each occasion prod is followed by 2 numbers - it's these numbers I need, but separately, not concatenated, but with each array element holding one of the numbers.  Later I'll work with the numbers.

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...
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>giftitem</p><br><p><img src="images/L_prod59.jpg"></p><p>giftitem2</p></div>

cheers.