question on converting string to an array

# Thread: question on converting string to an array

1. Senior Member
Join Date
Dec 1969
Posts
111

## question on converting string to an array

I am trying to figure out how to convert a set of strings into an array. <BR><BR>test1 = "test1"<BR>test2 = "test2"<BR>test3 = "test3"<BR><BR>I want these to end up in a array in test(1), test(2) and test(3)<BR><BR>Thanks,<BR><BR>Rudi<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
433

## RE: question on converting string to an array

test(0,1) = "test1"<BR>test(0,2) = "test2"<BR>test(0,3) = "test3"

3. Senior Member
Join Date
Dec 1969
Posts
111

## I think it's a little more complicated then t

The problem is that the original strings already contain values<BR><BR>Lets assume test1 already contains "Rudi" as a value.<BR>Now I want to put test1 into an array test(1) and have it retain the value "Rudi"<BR>

4. Senior Member
Join Date
Dec 1969
Posts
5,104

## RE: I think it's a little more complicated th

test1 = "Rudi"<BR>test2 = "Pam"<BR>test3 = "Bob"<BR><BR>Dim test(3)<BR> test(1) = test1<BR> test(2) = test2<BR> test(3) = test3<BR><BR>Actually, arrays are 0-based, so you would be doing:<BR>Dim test(2)<BR> test(0) = test1<BR> test(1) = test2<BR> test(2) = test3<BR><BR>What&#039;s the difficulty?<BR><BR>-Doug

5. Senior Member
Join Date
Dec 1969
Posts
111

## Here is the difficulty that i am facing

I guess I needed to add one more additional fatc sorry.<BR><BR>Since I have about 50 of these to go through with 15 fields each i want to do it with a for next loop, but what I am trying naturally does not work since it simply puts the name in.<BR><BR>so something like<BR><BR>for i = 1 to 50<BR>test(i) = "test"+cstr(i)<BR>next<BR><BR>Thanks,,<BR>Rudi

6. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: Here is the difficulty that i am facing

instead of naming each input with a different name, why don&#039;t you just name it the same name and do something like:<BR><BR>test = Request.Form("test")<BR>if test &#060;&#062; "" then<BR> arrTest = split(test, ", ")<BR> for i = 0 to ubound(arrtest)<BR> Response.Write arrTest(i) & "<BR>"<BR> next<BR>end if

7. Senior Member
Join Date
Dec 1969
Posts
5,104

## Where does test1..test2..

...test3...etc, come from?<BR><BR>-Doug

8. Senior Member
Join Date
Dec 1969
Posts
111

## RE: Where does test1..test2..

They are passed from a form request so basically hold the values of those fields in the previous form<BR><BR>Thnaks,<BR><BR>Rudi

9. Senior Member
Join Date
Dec 1969
Posts
5,104

## So, there are fields that are numbered?

Why not do what the other guy suggested?<BR><BR>Why put them into test1, test2, test3 in the first place?<BR><BR>-Doug

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•