|
-
Apr 5th, 2001, 07:09 AM
#1
Thread Starter
Hyperactive Member
Hello,
I have a textbox where the user can enter keywords which he must
"split" by using a comma. IE. forum,internet,webpage
How can I split whatever he entered, into different, single keywords
eg. he enters forum,internet,webpage - I now want to split it into
var1="forum"
var2="internet"
var3="webpage"
Any help please.
Thanks,
T
-
Apr 5th, 2001, 07:40 AM
#2
Why don't you use split function ?
stringObj.split([separator])
function SplitDemo(){
var s, ss;
var s = "The rain in Florida falls mainly in the plain.";
// Split at each space character.
ss = s.split(" ");
return(ss);
}
-
Apr 5th, 2001, 07:56 AM
#3
Fanatic Member
Hi turfbult
You can do the the following providing it is only a maximum of 3 words
Code:
Dim sVar1
Dim sVar2
Dim sVar3
Dim sString
Dim iCountFirst
Dim iCountSecond
sString = "forum,internet,webpage"
iCountFirst = InStr(1, sString, ",")
'more than one word
If iCountFirst > 0 Then
sVar1 = Mid(sString, 1, iCountFirst - 1)
'More than two words
If InStr(iCountFirst + 1, sString, ",") > 0 Then
iCountSecond = InStr(iCountFirst + 1, sString, ",")
sVar2 = Mid(sString, iCountFirst + 1, Len(sString) - iCountSecond + 1)
sVar3 = Mid(sString, iCountSecond + 1)
Else
sVar2 = Mid(sString, iCountFirst + 1)
End If
Else
sVar1 = sString
End If
Hope this helps
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|