Option Explicit
'===============================================
'Words.bas - string handling functions for words
'Author: Evan Sims [esims@arcola-il.com]
'Based on a module by Kevin O'Brien
'Version - 1.2 (Sept. 1996 - Dec 1999)
'
'These functions deal with "words".
'Words = blank-delimited strings
'Blank = any combination of one or more spaces,
' tabs, line feeds, or carriage returns.
'
'Examples:
' pword("find 3 in here", 3) = "in" 3rd word
' words("find 3 in here") = 4 number of words
' split("here's /s more", "/s") = "more" Returns words after split identifier (/s)
' delWord("find 3 in here", 1, 2) = "in here" delete 2 words, start at 1
' midWord("find 3 in here", 1, 2) = "find 3" return 2 words, start at 1
' wordPos("find 3 in here", "in") = 3 word-number of "in"
' wordCount("find 3 in here", "in") = 1 occurrences of word "in"
' wordIndex("find 3 in here", "in") = 8 position of "in"
' wordIndex("find 3 in here", 3) = 8 position of 3rd word
' wordIndex("find 3 in here", "3") = 6 position of "3"
'wordLength("find 3 in here", 3) = 2 length of 3rd word
'
'Difference between Instr() and wordIndex():
' InStr("find 3 in here", "in") = 2
' wordIndex("find 3 in here", "in") = 8
'
' InStr("find 3 in here", "her") = 11
' wordIndex("find 3 in here", "her") = 0
'===============================================
Public Function Pword(ByVal sSource As String, _
n As Long) As String
'=================================================
' Word retrieves the nth word from sSource
' Usage:
' Word("red blue green ", 2) "blue"
'=================================================
Const SP As String = " "
Dim pointer As Long 'start parameter of Instr()
Dim pos As Long 'position of target in InStr()
Dim x As Long 'word count
Dim lEnd As Long 'position of trailing word delimiter
sSource = CSpace(sSource)
'find the nth word
x = 1
pointer = 1






