ID : 285
InStr
Function
To return a position of a specific string within a string.
Syntax
InStr(start position, target, search string)
Guaranteed entry
- Start position
- Designate a position to start searching within the string of target by integer type. Designate a numeric value of 1 or higher.
- Target
- Designate a search target string by string type data.
- Search string
- Designate a string to search within the target string by string type data.
Return value
Return a position of search string found in the target string by integer type data.
Status of guaranteed items | Return value |
---|---|
The number of characters in a target string is 0 | 0 |
The number of characters in a search string is 0 | Value of start position |
Search string is not found | 0 |
Search string is found within a target string | Position of characters found |
Value of start position exceeds the number of characters in a target string | 0 |
Description
Look up a search string within the specified target from the left to the right. The search starts from the position that have been designated by the start position. Then a position where the search string is found first is returned.
Attention
-
Example
'!TITLE "Acquiring String Position"
' Acquire the first position where the search target "bc" is matched in a string "abcdefg"
Sub Sample_StrPos
Dim aaa As Integer
' Assign 2 indicating a position of "bc" within "abcdefg" to aaa
aaa = InStr( 1, "abcdefg", "bc" )
' Display 2 on the message output window
PrintDbg aaa
End Sub
ID : 285