compare in ASP by using StrComp function

We can compare two strings by using built in ASP function StrComp(). We can also specify different way of comparison by adding a third optional value in comparison. Here is the syntax of StrComp function.
StrComp(string1, string2, comparetype ) 

string1 and string2 are two string variables we are comparing, the value of comparetype ( Optional ) can be either 1 or 0. By default it is set to 0. If comparetype is set to 1 then lower case and upper case text are treated as same. If comparetype is set to 0 then ( or not entered ) then binary comparison is done so upper case letters comes before the lower case letter.

The output of the StrComp function gives output 0 if both the compared strings are equal and gives -1 if string1 is less than string2. It gives output 1 if string1 is greater than string2.

Here is the code for StrComp function comparing two strings.
Dim string1,string2
string1="Plus2net.com"
string2="plus2net.com"
Response.Write StrComp(string1,string2,0)
For different values of string1 and string2 with two values of comparetype the output we will get is given here in a table.

string1string2comparetypeOutput
Plus2net.complus2net.com0-1
Plus2net.complus2net.com10
Plus2net.comPlus2net.com00
Plus2net.comPlus2net.com10
plus2net.comPlus2net.com01
plus2net.comPlus2net.com10

ASP Home

plus2net.com





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