aRRAY pROBLEM

# Thread: aRRAY pROBLEM

1. Senior Member
Join Date
Dec 1969
Posts
162

## aRRAY pROBLEM

I got a &#060;textarea&#062; Form filed that the input will be:<BR><BR>email@domain.com,1<BR>email2@domain.com ,0<BR><BR><BR>This is just ONE Form field.<BR><BR>I need to convert each Line into and array<BR><BR>ArrEmail(0,0) = email@domain.com<BR>ArrEmail(1,0) = 1<BR><BR>How do I accomplish this? I can convert it to a 1d array but then I need to split that into a 2d array. How?<BR><BR>Thanks

2. Senior Member
Join Date
Dec 1969
Posts
162

## RE: aRRAY pROBLEM

I got this rioght now that works<BR><BR>emailimport = Request.form("emailimport")<BR>ArrEmail=split(emai limport,chr(13)&chr(10))<BR><BR>For I = 0 to ubound(ArrEmail)<BR>Response.write ArrEmail(i)<BR>&#039;This print out Each line but I need each line to be broken up by the comma<BR>&#039;Here I need to loop again and convert it to a 2D Array how?<BR>Next<BR>

3. Senior Member
Join Date
Dec 1969
Posts
162

## RE: Array Problem!

No One knows???????

4. Senior Member
Join Date
Dec 1969
Posts
162

## No One Knows arrays here????? (NT)

NT

5. Junior Member
Join Date
Dec 1969
Posts
23

## RE: aRRAY pROBLEM

If there are few enough to do all at once:<BR>arrFinal = Array( Split( "email@domain.com,0" ), <BR>Split( "email@domain.com,1" ),<BR>Split( "email@domain.com,2" ) )<BR><BR>Or if you have a large or unknown amount, step through<BR>with a ReDim.<BR>

6. Senior Member
Join Date
Dec 1969
Posts
162

## RE: aRRAY pROBLEM

Huh????<BR><BR>Can you explain more in detail?

7. Senior Member
Join Date
Dec 1969
Posts
162

## RE: That makes no sense

I have an array already. What are you talking about????<BR><BR>Where did you get Array( Split( "email@domain.com,0" ),

8. Junior Member
Join Date
Dec 1969
Posts
23

## RE: That makes no sense

Please define your problem more clearly. I got the impression you had cgi values and were trying to get them into a 2d array.<BR>Since Split() and Array() return both return arrays, then you would end up with an array of arrays which can be treated like a 2D array. What exactly do you have and what exactly do you want?

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## I'll trade you...

YOU explain what POSSIBLE reason you have for converting to a 2D array and I&#039;ll tell you the silly code you need to do it.<BR><BR>An array *of* arrays would almost surely be more efficient, you know?<BR><BR>&#060;%<BR>theArray = Split( text, vbCRLF ) <BR>For i = 0 To UBound( theArray )<BR>&nbsp &nbsp; theArray(i) = Split( theArray(i), "," )<BR>Next<BR>%&#062;<BR><BR>What&#039;s wrong with that? Now, to reference a specific row and column, you use:<BR><BR>&#060;%<BR>cell = theArray( row )( column )<BR>%&#062;<BR><BR>But if you insist on the 2D array (I&#039;m cheating by telling you this before making you explain why):<BR><BR>&#060;%<BR>temp1 = Split( text, vbCRLF ) <BR>Dim theArray( )<BR>ReDim theArray( 1, UBound(temp1) )<BR>For i = 0 To UBound( temp1 )<BR>&nbsp &nbsp; temp2 = Split( temp1(i), "," )<BR>&nbsp &nbsp; theArray(0,i) = temp2(0)<BR>&nbsp &nbsp; theArray(1,i) = temp2(1)<BR>Next<BR>%&#062;<BR><BR>See? That wasn&#039;t really hard at all? But I still can&#039;t figure out how it&#039;s better than the array-of-arrays that is the simpler solution.<BR>

10. Senior Member
Join Date
Dec 1969
Posts
162

## RE: I'll trade you...

Well for one your examples give me a:<BR><BR>Microsoft VBScript runtime error &#039;800a0009&#039; <BR><BR>Subscript out of range <BR><BR>Error.

#### Posting Permissions

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