seperating words
-
- Veteran
- Posts: 703
- Joined: Sun Nov 14, 2004 7:36 am
- Contact:
Hi there Guest
.
There's no functions that does that per se no. However, here's a small function that will do that for you.
Hope this helps.

There's no functions that does that per se no. However, here's a small function that will do that for you.
Code: Select all
' ========================================================
' NAME........: GetWordNumber()
' PARAMETERS..: WorkString AS STRING
' WordNumber AS LONG
' RETURN......: "" Or the desired word Number
' ASSUMES.....: WorkString has contents, WordNumber > 0
' CALLED FROM.: Anywhere
' --------------------------------------------------------
' DESCRIPTION.: This function accepts a string and a
' Word Number as paremeters, it then finds
' the given word number and returns it to
' the calling function.
' ========================================================
FUNCTION GetWordNumber(WorkString AS STRING, WordNumber AS LONG) AS STRING
' ----------------
' Work Variables
' ----------------
DIM Counter AS LONG
DIM WordCounter AS LONG
DIM Position AS LONG
DIM Skipper AS LONG
DIM ReturnString AS STRING
' ----------------------
' Initialize Variables
' ----------------------
WordCounter = 1
Position = 1
ReturnString = ""
' ---------------------------------------------------------
' First we put ourselves at the beginning of the 1st word
' ---------------------------------------------------------
IF MID$(WorkString, Position, 1) = " " THEN
DO WHILE MID$(WorkString, Position, 1) = " "
Position = Position + 1
LOOP
END IF
' --------------------------------------
' Then we start the Word Count Process
' --------------------------------------
FOR Counter = Position TO LEN(WorkString)
IF MID$(WorkString, Counter, 1) = " " THEN
WordCounter = WordCounter + 1
DO WHILE MID$(WorkString, Counter, 1) = " "
Counter = Counter + 1
LOOP
END IF
' ----------------------------------------------------------
' If it's the wanted word number we put it in ReturnString
' ----------------------------------------------------------
IF WordCounter = WordNumber THEN
IF MID$(WorkString, Counter, 1) <> " " THEN
ReturnString = ReturnString + MID$(WorkString, Counter, 1)
END IF
END IF
NEXT Counter
' ---------------------------------
' Return the word in ReturnString
' ---------------------------------
GetWordNumber = ReturnString
END FUNCTION
When God created light, so too was born, the first Shadow!
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com