StrComp - Built-in String Function¶
Purpose¶
StrComp compares two strings and returns an integer indicating the result of the comparison.
Syntax¶
StrComp(str1, str2 [,bool])
Arguments¶
| Argument | Required | Description |
|---|---|---|
str1 |
Yes | Any valid string expression |
str2 |
Yes | Any valid string expression |
bool |
No | Any valid Boolean expression indicating if the comparison is case insensitive |
Returns¶
Integer
Return values:
| Return value | Meaning |
|---|---|
-1 |
str1 is lesser than str2 |
0 |
str1 is equal to str2 |
1 |
str1 is greater than str2 |
Example¶
// Example case sensitive compare:
Let sStr1 = "ABCD"
Let sStr2 = "abcd"
// This is a case sensitive comparison.
Return StrComp(sStr1, sStr2, 0) // returns -1 (less than)
// Example case insensitive compare:
Let sStr1 = "ABCD"
Let sStr2 = "abcd"
// This is a case insensitive comparison.
Return StrComp(sStr1, sStr2, true) // returns 0 (equal to)
See Also¶
Notes¶
- When the arguments cannot be converted to the specified type, a runtime error is generated.
- If
boolis omitted, the search will be case-sensitive.