|
-
February 27th, 2000, 04:18 AM
#1
help with strings
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
-
February 27th, 2000, 08:22 AM
#2
Re: help with strings
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
[email protected]
The best way to escape a problem, is to solve it.
-
February 28th, 2000, 03:41 AM
#3
Re: help with strings
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", " " )
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
|