February 27th, 2000, 03:18 AM
i have a function that takes one large string. the string has tree words.
"computer screen button". there is space between them. i need a code for parssing this string. i want to put each word in array.
thanks
Cakkie
February 27th, 2000, 07:22 AM
If i'm correct, you want to place every word seperated with a space, into a string? Ok, try this:
dim myArray() as string
public chopThemUp(strToChop as string)
dim myCount as integer
myCount = 1
redim myArray(myCount)
for t=1 to len(strToChop)
' get one character
myChar = mid(strToChop,t,1)
if mychar = " " then
' if a space, create new array element
myCount = myCount + 1
redim preserve myArray(myCount)
else
' when not a space, add char to last array element
myArray(myCount-1) = myArray(myCount-1) & myChar
end if
next t
end sub
This code will place all words into seperate array elements by doing a check on each character, if it's a space, it will create a new array element, if not, it will append the char to the last element of the char.
Tom Cannaerts
slisse@planetinternet.be
The best way to escape a problem, is to solve it.
Lothar Haensler
February 28th, 2000, 02:41 AM
in VB 6 there is a split function that allows you to do that in one line.
dim a() as string
a = split("yourstringgoes here", " " )