|
|
 |
Looping through an array
david2105 | Posted 7:56am 29. October 2003 Server Time |
Guys,
I have four arrays (COList, CodeList, AmtList, ItemList). I need to loop through the array and for each unique item in the ItemList array I need to add it into another array along with the corresponding Amt in AmtList.
If when we loop through the item array we find an existing item then we want to add the amt to the current amt in the array for that item.
This is what I have tried so far. But it doesn't work. The items in the array seem to be overwriting each other.
Does anyone have any other ideas?
Cheers, David2105
<% COList = CSTR(Request.Form("tCOs")) CodeList = CSTR(Request.Form("tCodes")) AmtList = CSTR(Request.Form("tAmts")) ItemList = CSTR(Request.Form("tItems"))
COList = trim(Right(COList, Len(COList)-1)) CodeList = trim(Right(CodeList, Len(CodeList)-1)) AmtList = trim(Right(AmtList, Len(AmtList)-1)) ItemList = trim(Right(ItemList, Len(ItemList)-1))
COArray = Split(COList, ",") CodeArray = Split(CodeList, ",") AmtArray = Split(AmtList, ",") ItemArray = Split(ItemList, ",")
ReDim ProcItemArray(1, CINT(UBOUND(COArray))+1) ReDim ProcUsedArray(2, CINT(UBOUND(COArray))+1)
FOR k = 0 TO UBOUND(COArray) ProcItemArray(0,k) = "" ProcItemArray(1,k) = "" ProcUsedArray(0,k) = "" ProcUsedArray(1,k) = "" ProcUsedArray(2,k) = "" NEXT
For i = 0 TO UBOUND(ItemArray) FOR J = 0 TO Ubound(ItemArray) IF ProcItemArray(0,i) = "" THEN ProcItemArray(0,i) = ItemArray(j) END IF IF ProcItemArray(0,i) = ItemArray(j) THEN ProcItemArray(1,i) = cdbl(ProcItemArray(1,i) + AmtArray(j)) ELSE ProcItemArray(0,i) = ItemArray(j) ProcItemArray(1,i) = cdbl(AmtArray(j)) Response.Write "<h1>" & ProcItemArray(0,i) & "</h1>" END IF
IF ProcUsedArray(0,i) = ItemArray(j) AND ProcUsedArray(1,i) = AmtArray(j) THEN ProcUsedArray(2,i) = cdbl(ProcUsedArray(2,i) + 1) ELSE ProcUsedArray(0,i) = ItemArray(j) ProcUsedArray(1,i) = cdbl(AmtArray(j)) ProcUsedArray(2,i) = 1 END IF NEXT' J increment loop (ItemArray)
Next %>
|
david2105 | Posted 2:37am 30. October 2003 Server Time |
Anybody got any ideas how to do this. It's the last hurdle in a project I was hoping to close by tomorrow.
Cheers guys, David2105
findel | Posted 3:57am 30. October 2003 Server Time |
---------------------------------- For i = 0 TO UBOUND(ItemArray)
FOR J = 0 TO Ubound(ItemArray) ----------------------------------
Should this be calling two different Arrays?
if so, but the UBOUND for both intho vairables.
david2105 | Posted 7:33am 30. October 2003 Server Time |
Fin,
thanks for looking but I found another way using the scripting dictionary to add unique values then rewrite them into an array.
Thanks, David2105
kiki | Posted 6:01am 12. October 2010 Server Time |
<a href="http://www.viagra.gd"> viagra</a> this can be <a href="http://www.viagraonline.us"> viagra online</a> done it is <a href="http://www.viagra-no-prescription.us"> viagra no prescription</a>
kiki | Posted 6:02am 12. October 2010 Server Time |
[url=http://www.viagra.gd] viagra[/url] [url=http://www.viagraonline.us] viagra online[/url] [url=http://www.viagra-no-prescription.us] viagra no prescription[/url]
kiki | Posted 6:02am 12. October 2010 Server Time |
http://www.viagraonline.us
hedi01 | Posted 6:14pm 13. December 2010 Server Time |
I had heard many good things about the show[url=http://www.dvdtopshop.com/en/comedy/greys-anatomy-seasons-1-6-dvd-boxset.html]grey's anatomy dvd[/url] and was pleasantly surprised to find that when you look at a handful of season DVD - G[url=http://www.dvdtopshop.com/en/sci-fi-fantasy-/smallville-seasons-1-9-dvd-boxset.html]smallville dvd[/url]rey's Anatomy, I was hooked, and I love every episode. They are now awaiting the arrival[url=http://www.dvdtopshop.com/en/animation-cartoons/walt-disneys-100-years-of-magic-164-discs-dvd-boxset.html]walt disney dvd[/url] of the second season. Great show, very funny, very interesting character and plot development. Much more show.I hospital are a medical doctor [url=http://www.dvdtopshop.com/en/tv-series-dvd-boxset/house-m-d-seasons-1-6-dvd-boxset.html]house md dvd[/url]so what makes me cringe, and I'll take it. Yet there are those moments when I saw all the episodes of the actors address real [url=http://www.dvdtopshop.com/en/thrillers-crime-mystery-/24-hours-twenty-four-seasons-1-8-dvd-boxset.html]24 hours dvd[/url]human emotions and frustration. Then I almost forgot that I expect more of the same sort St.Elsewhere / ER "Let's Play Doctor"trash. This is not spam .... entertainment.The throw it almost unbelievable!
Show all replies to 'Looping through an array'
|
This post have been closed for new replies
|
|
|
|
 |
|