| << 4.7.4- Removing the Middle of a String | Chapter4 | 4.7.6- Giving it a Quick Trim >> |
Finding a Particular Word
Of course, there will be times when you want to find a particular word within a string and the point where it occurs. The functionthat will do this for you is InStr. This functionrequires the string itself, and the text to be located as parameters:
InStr(string, text_to_be_located)
In our example, we can use it to isolate a particular wordand return its position in a string.
strText ="HowLongIsAPieceOfString?"
intwhere =InStr(strText,"Long")
This example would return the number 4, as the word"Long" starts on the fourth character. However, InStr is also case-sensitive, so if you searched for"long" instead of "Long", you wouldn't find it at all. Inthis case InStr returns the value 0.
| << 4.7.4- Removing the Middle of a String | Chapter4 | 4.7.6- Giving it a Quick Trim >> |

RSS

