Function InStr
|
Returns the position of the first occurrence of one string within another.
Native to VB5 and VB6 (actually to all versions of VB, even to all versions of BASIC, AFAIK).
|
VBspeed's Declaration:
|
InStr(sCheck, sMatch[, Start[, Compare]])
|
VB's native Declaration:
|
VB's InStr, of course, looks like this (with the optional Start parameter as the first argument, a weird setup if you ask me):
InStr([Start, ]sCheck, sMatch[, Compare])
|
Arguments:
|
sCheck | Required. String expression being searched.
|
sMatch | Required. String expression being searched for.
|
Start | Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position (Start = 1).
|
Compare | Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. If omitted, a binary comparison is performed.
|
Return Values:
|
Typical cases:
InStr("abc", "a") => 1
InStr("abc", "b") => 2
Special cases:
sCheck is zero-length => 0
sMatch is zero-length => start
sMatch is not found => 0
Start > Len(sMatch) => 0
|
Roll your own
|
If you want to have a go at InStr yourself, use this function (VB5/6-compatible) to verify the correctness of your code.
|