InStr

Return the position of one string within another, starting at the beginning of the string.

Syntax
      Instr ( [start], FullString, PartString, [compare] )

Key
   Start       Number (expression) that sets the start position for each search.
               Default=1

   FullString  The String (expression) to be searched.

   PartString  The String (expression) being sought.

   compare     The comparison mode (Binary/Text)

The InStr() function may be used in VBA or in an SQL query.

Return values

If

InStr returns

FullString is zero-length

0

FullString is Null

Null

PartString is zero-length

start

PartString is Null

Null

PartString is not found

0

PartString is found within FullString

Position at which match is found

start > FullString

0

Example

Dim intDemo as Integer

intDemo = InStr("The Universe is everlasting ", "U")
MsgBox intDemo

intDemo = InStr(4, "The Universe is everlasting", "e")
MsgBox intDemo

“Believe those who are seeking the truth; doubt those who find it” ~ Andre Gide

Related:

InstrRev - Return the position of one string within another
Replace - Replace a sequence of characters in a string.



Back to the Top

© Copyright SS64.com 1999-2013
Some rights reserved