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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split string

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi all,

i am a newbie to asp and i have given a project with a very short time period.

i have a text box where a user can enter a keywords seperated by comma for search.
i am comparing this keywords with a value in database.
now in order to do that i have to split the keyword string on comma.
can someone tell me how to do that? a code will be great because i am struggling with the syntax.

thanks in advance

new_to_asp
 
temp="gfdddfg,jgfhfgf"

str = instr(1,temp,",",1)
Response.Write str


This will basically give you 8 using the textual comparison.. u could use if instr(blabla) <> 0 then whatever you are doing with recordsets, something slike

if instr(1,Request.form(&quot;youtextfield&quot;,rs.Field(&quot;columnname&quot;),1 ) <> 0 then

ok
else
Error
End if

Tick as usefull if happy Regards gsc1ugs
&quot;Cant see wood for tree's...!&quot;
 
wouldn't you want something like
MyString = &quot;123,456,789&quot;
MyArray = Split(MyString, &quot;,&quot;)?
result:
MyArray(0) = &quot;123&quot;
MyArray(1) = &quot;456&quot;
MyArray(2) = &quot;789&quot;
 
thanks for the help guys

Howevere i dont know how many keywords the user will enter

so i did it like this

key = split(str,&quot;,&quot;)

for i=0 to ubound(key)
response.write(key(i))
next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top