-
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
-
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);
}
-
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