Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Functions
FUNCTION: StrComp( )
StrComp
(String1, String2,
Compare
)
The
StrComp
function compares two strings to see if they are the same. You can have the comparison be sensitive, or not, to the case (upper versus lower) of the characters in the two strings. The default is to be case sensitive (binary comparison).
If the strings are the same, the output is zero. If the strings are different, the output will be a 1 or -1 depending on the order of the strings.
There are two mandatory arguments.
String1
The
String1
argument is the first of two strings to compare.
String2
The
String2
argument is the second of two strings to compare.
Code:
<% =StrComp("Mountains of the Moon", "Mountains of the Moon") %>
Output:
0
Code:
<% =StrComp("Mountains of the Moon", "Red sails at sunset") %>
Output:
-1
There is one optional argument.
Compare
The optional
Compare
argument can be used to set whether the comparison is case sensitive (upper versus lower), or not. You must only use the constant or the value of the COMPARISON CONSTANTS.
CONSTANT
VALUE
DESCRIPTION
VBBinaryCompare
0
Binary comparison
(case sensitive)
VBTextCompare
1
Text Comparison
(case insensitive)
Code:
<% =StrComp("Mountains of the Moon", "mountains of the moon", 0) %>
Output:
-1
Code:
<% =StrComp("Mountains of the Moon", "mountains of the moon", 1) %>
Output:
0
Code:
<% =StrComp("RED", "red", VBTextCompare) %>
Output:
0
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information