StrComp() String Comparison in Classic ASP

StrComp() compares two strings and returns -1, 0 or 1 depending on their ordering/equality.

Syntax

StrComp(string1, string2, comparetype)

Use vbBinaryCompare (0) for a binary comparison or vbTextCompare (1) for a textual comparison. Naming the constant is clearer than leaving an unexplained numeric value in application code.

Example

Dim string1, string2
string1="Plus2net.com"
string2="plus2net.com"
Response.Write StrComp(string1, string2, vbBinaryCompare)
string1string2compareResult
Plus2net.complus2net.comvbBinaryCompare-1
Plus2net.complus2net.comvbTextCompare0
Plus2net.comPlus2net.comvbBinaryCompare0
plus2net.comPlus2net.comvbBinaryCompare1

If either argument is Null, the comparison result is Null. Choose binary or text comparison deliberately rather than assuming every comparison should ignore case.


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer