string manipulation - seperate everyting before the underscore and after

B

Bob Barrows

jason said:
How do I seperate the "chk_" and "33" in the following string:

chk_33

Thanks Jason

dim ar, str
str = "chk_33"
ar=split(str,"_")
'ar(0) contains "chk"
'ar(1) contains "33"

HTH,
Bob Barrows
 
J

jason

Thanks - but I cannot do it that way because I may have other form values
seperated by an "_" underscore eg: "address_1"

My form collection will be returning:
chk_69
chk_33
chk_32
etc
txt_12
etc

....I don't think that function will do the trick?
 
J

jason

...I should rephrase that:

When I iterate the form collection I need to isolate all the controls which
have the prefix: "chk_"

....and then complete the seperation - is this possible?

-Jason
 
A

Aaron Bertrand [MVP]

Thanks - but I cannot do it that way because I may have other form values
seperated by an "_" underscore eg: "address_1"

Can't you control that, and *not* that character for other meaningless
separations?

If you really must support something like chk_address_1 then look at the
MID() and INSTR() functions.
 
A

Alan

Jason,

Most of your posts today relate to our original exchage. Please check out my
reply to you under the 'Re: Multiple insert - iterate form collection -
checkbox name dynamic?' thread. The rest of your queries will be answered
too.

Cheers,

Alan
 
B

Bob Barrows

jason said:
Thanks - but I cannot do it that way because I may have other form
values seperated by an "_" underscore eg: "address_1"

So? ar(0) will contain "address" and ar(1) will contain "1"? What's the
problem?
My form collection will be returning:
chk_69
chk_33
chk_32
etc
txt_12
etc

...I don't think that function will do the trick?

Why not? You don't know how to use an If statement? Try this:

for each x in request.form
'check to see if a "_" is present:
if instr(x,"_")>0 then
ar=split(x,"_")
if ar(0) = "chk" then
'we have a winner - do what you want with the variable:
y = ar(1)
else
'do nothing
end if
end if
next

Bob Barrows
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top