STRCOMP(string1, string2 [,compare])

Returns the result of a string comparison (Integer).


string1The first text string (String).
string2The second text string (String).
compare(Optional) A vbCompareMethod constant specifying the type of string comparison to use (Integer):
-1 = vbUseCompareOption (uses the "Option Compare" setting)
0 = vbBinaryCompare
1 = vbTextCompare
2 = vbDatabaseCompare (uses an Access database)

REMARKS
* The value returned is -1 when "string1" is less that "string2".
* The value returned is 0 when "string1" is equal to "string2".
* The value returned is 1 when "string1" is greater than "string2".
* The value returned is Null if either "string1" or "string2" is Null.
* If "compare" is Null, then an error occurs ??
* If "compare" is left blank, then -1 is used, ie the module's string comparison setting is used.
* You can use the STRCOMP$ function to return a String data type instead of Variant/String data type.
* If you type in STRCOMP$ with valid arguments the editor will automatically change this function to just STRCOMP.
* The equivalent .NET function is Microsoft.VisualBasic.Strings.StrComp
* For the Microsoft documentation refer to docs.microsoft.com

StrComp("text", "text", vbBinaryCompare) = 0 
StrComp("text ", "text", vbBinaryCompare) = 1
StrComp("Text", "text", vbBinaryCompare) = -1
StrComp("Text", Null, vbBinaryCompare) = Null
StrComp("text", "text", vbTextCompare) = 0
StrComp("text ", "text", vbTextCompare) = 1
StrComp("Text", "text", vbTextCompare) = 0
StrComp(Null, "Text", vbBinaryCompare) = Null
StrComp("3-D Settings Toolbar", "3D References", vbTextCompare) = 1
StrComp("3-D Settings Toolbar", "3D Trendlines", vbTextCompare) = -1

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top