Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

InStr

  • Last UpdatedJul 18, 2023
  • 1 minute read

Returns the character position of the first occurrence of String2 within String1.

Syntax

InStr(StartPos, StringToSearch, StringToMatch )

StartPos:

A numeric expression that sets the starting position for the search. If omitted, search begins at the first character position. If Num contains Null, an error occurs. An Integer or expression representing a valid numeric value.

StringToSearch:

The string expression being searched. A string or expression that can represent a valid text value.

StringToMatch:

The string expression being searched for. A string or expression that can represent a valid text value.

Return Value

Returns a variant containing a Long data type indicating the result of the string search. Returns 0 if:

  • StringToSearch is of zero length.

  • StringToMatch is not found.

  • StartPos is longer than StringToMatch.

Returns a value representing the count position where character match was first found.

Returns Null if StringToSearch or StringToMatch contains null.

IsNull | Left, Left$ | Mid | Right | StrComp

Example

Dim strToSearch as String
Dim strToFind as String
Dim lngPosition as Long
strToSearch = "Good Bye"
' note this has an uppercase "B"
strToFind = "bye"
' note this has a lowercase "b"
lngPosition = InStr(1, strToSearch, strToFind, 0)
' returns 0 (Did not find match)
lngPosition = InStr(1, strToSearch, strToFind, 1)
' returns 6 (Position of first character in match)

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in