?
Solved

Split an Array Twice

Posted on 2009-12-29
4
Medium Priority
?
320 Views
Last Modified: 2012-05-08
Hello:

I have values that look like this after the first split
4|Yes 0|No 999|Neutral 2|Yes 1|No 6|No 2|Yes 999|Neutral 1|Yes 2|Yes 8|No

What I am trying to do is get the values to look like this:
4
Yes
0
No
etc....

The script run about half way and then errors out.
Microsoft VBScript runtime error '800a0009'

Subscript out of range: 'i'

<%
arrQues=Split(request("Ques"),",")
ID=split(request("QID"),",")
For i=0 to ubound(ID)
ValQues = Split(arrQues(i),"|")
Response.Write ValQues(i)
Response.Write "<br>"
Next
%>

Open in new window

0
Comment
Question by:RecipeDan
  • 2
4 Comments
 
LVL 7

Expert Comment

by:whosbetterthanme
ID: 26139383
Try adding LBound to the for loop:

For i = LBound(ID) to UBound(ID)
ValQues = Split(arrQues(i),"|")
Response.Write ValQues(i)
Response.Write "<br>"
Next

Open in new window

0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26139410
try this mate

<%
str ="4|Yes 0|No 999|Neutral 2|Yes 1|No 6|No 2|Yes 999|Neutral 1|Yes 2|Yes 8|No"

spl1_Str = split(str,"|")
For each splind in split(str,"|")
	 for each spl_second in split(splind," ")
	  Response.Write(spl_second)
	  Response.Write("<br>")
	 next
next 
%>

Open in new window

0
 
LVL 1

Author Comment

by:RecipeDan
ID: 26139549
meeran03 that works, but I am not always goint to have this value
str ="4|Yes 0|No 999|Neutral 2|Yes 1|No 6|No 2|Yes 999|Neutral 1|Yes 2|Yes 8|No"

0
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 2000 total points
ID: 26139726
I had done an example which split to two variables  as u presented ur example in the question .

Two condition >>
First one is |
second one is space

If these are the condition need to be checked
>>just assign  the str values with ur changing values

For eg > If ur reading from db  replace str values with this ...
str = dr("twosplitfield")

Hope it helps
Meeran 03



0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question