breaking a string into components

T

Thomas Brooks

Hi everybody....

Here's a question for you. I think the answer is simple, but I'm not sure
how to go about it...what I want to do is to break down a string into
components. I already know about the LEFT, MID, and RIGHT properties, but I
don't believe they'll work in this case. Anyway:

I have an ASP page where I retrieve data off of a database
recordset...something like:

variable1=RecSet1(0)

the data stored in RecSet1(0) is something like AA,BB,CC,DD,EE or there may
even be spaces like AA, BB, CC, DD, EE

what I would like to do is to set up some new variables as pieces of the
string....so,

newvariable1 = whatever is to the left of the first comma
newvariable2 = whatever is between the first and second comma

etc...

I can trim out spaces later....I just need to know how to gather pieces in
front of, in between, or after a delimiter like a comma

Thanks

Tom
 
S

Steven Burn

Look at the Split function.

e.g. strThingymibob = Split(strData, ",") 'Split via comma

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
R

Ray at

How about using an array and splitting, like so:

<%
sString = "AA, BB, CC, DD, EE"
sString = Replace(sString, " ", "") ''optional. Might want to replacey ", "
with "," or do nothing at all
aParts = Split(sString, ",")

For i = 0 To UBound(aParts)
Response.Write "Part " & CStr(i + 1) & " is " & aParts(i) & "<br>"
Next
%>

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top