Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spliting a string into an array by " 1

Status
Not open for further replies.

theocraticmind

Programmer
Apr 19, 2002
318
CA
i'd like to use the split() sunction to split a string into an array, moving to a new part every ". but i'm not sure how... i'g getting this error when i try the logical way:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/dfxboard/new_topic.asp, line 24

aray() = split(string1,""")
---------------------------^

this is in a function. so string1 is not given a value until the function is called. i'm not sure what it meant by "Unterminated string constant" but i'm asuming it has to do with the """... any help would be great
 
try aray() = split(string1, """") 'there's 4 there
 
Dear TheoreteicMind
You can use

const ArraySep = """"
dim StData
StData = Split(straData, ArraySep )

'Now you can use stData(0),stData(1) and so on......


Hope it will help you
Regards
Nouman
 
Or
aray()=split(string1,chr(34))

chr(34) is a "
 
I have been using chr(34) a lot in com components simply because I did not know of the "".
Now I prefere the "".

.write ".... onClick=" & chr(34) & "alert('hi');" & chr(34) & ">"
This is such a pita and this:
.write ".... onClick=""alert('hi');"">"
Is the same.

In your case script like this works allso:

dim str
dim arr
str = "nul""one""two"
arr = split(str,"""")
i = 0
do until i > ubound(arr)
Response.Write arr(i) & &quot;<br>&quot; & vbcrlf
i = i + 1
loop


What you did wrong the first time is that you were missing one &quot; character in your split function you had(&quot;&quot;&quot;) should have been (&quot;&quot;&quot;&quot;).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top