Word$ (function)

Syntax Word$ (text$,first[,last])
Description Returns a String containing a single word or sequence of words between first and last.
Comments The Word$ function requires the following parameters:
Parameter Description
text$ String from which the sequence of words will be extracted.
first Integer specifying the index of the first word in the sequence to return. If last is not specified, then only that word is returned.
last Integer specifying the index of the last word in the sequence to return. If last is specified, then all words between first and last will be returned, including all spaces, tabs, and end-of-lines that occur between those words.
Words are separated by any non-alphanumeric characters such as spaces, tabs, end-of-lines, and punctuation. If first is greater than the number of words in text$, then a zero-length string is returned. If last is greater than the number of words in text$, then all words from first to the end of the text are returned.
Example This example finds the name "Stuart" in a string and then extracts two words from the string.
Sub Main()
  s$ = "My last name is Williams; Stuart is my surname."
  c$ = Word$(s$,5,6)
  MsgBox "The extracted name is: " & c$
End Sub
See Also Item$ (function); ItemCount (function); Line$ (function); LineCount (function); WordCount (function).