What is the StrComp function?
What is the StrComp function?
Rating:
The StrComp function is used to compare two strings alphabetically. The function takes three parameters. It is defined as follows:
where, the first two parameters to the function (i.e., Str1 and Str2) are any valid String expressions that are to be compared. The third parameter (i.e., CompareMethod) is optional. If this parameter is not present, the Option Compare setting in the module determines the type of comparison. If this parameter is present, then it specifies the criteria of string comparison (either Binary or Text). If the Text comparison method is used, Visual Basic will ignore case when comparing letters. If the Binary comparison method is used, the case of the letters will matter.
The StrComp function returns the following values:
| | |
| -1 | If Str1 comes before Str2 in a sort based on ASCII code. |
| 0 | If Str1 is equal to Str2. |
| +1 | If Str1 comes after Str2 in a sort based on ASCII code. |
Rating:
Other articles
- What is the ExecuteScalar method?
- What is a Windows service?
- What is DTD?
- How to change the Configuration property of a Visual Basic .NET project?
- What is Locals window?