Vbscript StrComp string comparison function provides the functionality to compare the two string values. Vbscript StrComp function returns number values such as -1, 0 or 1 based the comparison between the specified string expressions. If both string values specified as parameters of vbscript StrComp function are same then it returns 0. Returned value as 0 means both the string expressions are equal.
StrComp( string1, string2, compare)
StrComp function of vbscript accepts 3 types of parameters to compare the strings as shown in the above syntax.
Expected Results of Vbscript StrComp function
If string1 < string2, strComp returns -1.
If string1 > string2, it returns 1
If string1 = string2, it returns 0
Example 1:
<%
Dim myString1
myString1 = "Vbscript StrComp Function"
myString2 = "vbscript strcomp function"
Response.Write(StrComp(myString1, myString2))
%>
Output:
-1
Example 2:
Response.Write(StrComp(myString1, myString2, vbTextCompare))
0
Example 3:
Response.Write(StrComp(myString2, myString1))
1
Be the first to rate this post
Tags: vbscript, asp, vbscript strcomp, vbscript string functions, vbscript right, vbscript instrrev, vbscript mid, vbscript replace, vbscript trim, vbscript ltrim, vbscript rtrim, vbscript left, vbscript instr, vbscript lcase, vbscript ucase, vbscript len, vbscript strreverse, vbscript strcomp string function, vbscript space, vbscript string function
8/23/2008 8:58:09 PM