Page

4.7.5- Finding a Particular Word

  by NT Community Manager.
Last Updated  by NT Community Manager.  

PublicCategorized as 04. Variables.

Not tagged.
<< 4.7.4- Removing the Middle of a StringChapter44.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 StringChapter44.7.6- Giving it a Quick Trim >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |