Solved

# Array from loop

Posted on 2013-01-15
248 Views
Hi!
I have a simple problem with arrays.

I want to build an array of a loop, then i want to store the result in a variable.

I have a loop like this:

wend

And if there is more than one sparepart then i want to seperate them with an break and then i want to store this in a variable named spareparts and the output will be:

sparepart1
sparepart2
...

I will use the variable in an mailcomponent. Can you help me, i know that this is basic, but i am in a hurry and i am really bad at arrays :-)
0
Question by:MickeC

LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
you would do like this:

``````Dim spare_parts
spare_parts = ""

wend

response.write spare_parts
``````

you can replace the "<br>" by whatever you mail component will need as "break".
this is a non-array solution...
0

LVL 18

Expert Comment

Here is how you create an array of N size, adding to it as you loop through your object.
In this example, I merely loop through the numbers 1 through 10.
``````<%
Dim arrSpareParts()
Dim i
i=0

While i < 10
Redim Preserve arrSpareParts(i)
arrSpareParts(i) = "Value_" & i
i = i + 1
Wend

For Each item In arrSpareParts
Response.Write(item & "<br />")
Next
%>
``````

``````<%

Dim arrSpareParts()
Dim i

i=0

Redim Preserve arrSpareParts(i)
i = i + 1
wend

For Each item In arrSpareParts
Response.Write(item & "<br />")
Next
%>
``````

A little bit cleaner, but I'm not sure if I have the syntax correct for rsSpare.Index, would be something like this (not sure if the first value is 0 or 1 - if it is 1, then you will want to subtract 1 from it so that the first item in your array is number 0:
``````<%

Dim arrSpareParts()
Dim i

Redim Preserve arrSpareParts(i)
wend

For Each item In arrSpareParts
Response.Write(item & "<br />")
Next
%>
``````
0

## Featured Post

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…