WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE
The StrComp function compares two strings and returns a value that
represents the result of the comparison. Returns a value indicating
the result of a string comparison. 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.
The StrComp function can return one of the following values :-
If |
StrComp returns |
string1 is less than string2 |
-1 |
string1 is equal to string2 |
0 |
string1 is greater than string2 |
1 |
string1 or string2 is Null |
Null |
The Syntax of the StrComp function is :-
StrComp(string1,string2[,compare]) |
Its Description is :-
Parameter |
Description |
string1 |
Required. A string expression |
string2 |
Required. A string expression |
compare |
Optional. Specifies the string comparison to use. Default
is 0
Can have one of the following values:·
- 0 = vbBinaryCompare - Perform a binary comparison.
- 1 = vbTextCompare - Perform a textual comparison
|
Example#1 :-
Code :-
document.write(StrComp("VBScript","VBScript"))
Output :-
0 |
Example#2 :-
Code :-
document.write(StrComp("VBScript","vbscript"))
Output :-
1 |
Example#3 :-
Code :-
document.write(StrComp("VBScript","vbscript",1))
Output :-
0 |
Example#4 :-
Code :-
document.write(StrComp("hallo","hallo"))
Output :-
0 |
There are Two Mandatory Arguments :-
Example#5 :-
It explains the String1 Argument
Code :-
<%
=StrComp("Mountains of the Moon", "Mountains
of the Moon")
%>
Output :-
0
|
Example#6 :-
It explains the String 2 Argument
Code :-
<%
=StrComp("Mountains of the Moon", "Red sails
at sunset")
%>
Output :-
-1 |
Example#7 :-
It explains the Compare Argument
Code :-
<%
=StrComp("RED", "red", VBTextCompare)
%>
Output :-
0
|
|