adsense


Sunday, 8 November 2015

VB SCRIPT STRCOMP FUNCTION PAGE 51

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




VB SCRIPT STRCOMP FUNCTION





StrComp Function 


The StrComp Function returns an integer value after comparing 
the two given strings. It can return any of the three values -1, 0 or 1 
based on the input strings to be compared. 

• If String 1 < String 2 then StrComp returns -1 

• If String 1 = String 2 then StrComp returns 0 

• If String 1 > String 2 then StrComp returns 1 

Syntax 
StrComp(string1,string2[,compare])  
 
Description 

• String1, a Required Parameter. The first String expression. 

 

• String2, a Required Parameter. The second String expression. 

 

• Compare, an Optional Parameter. Specifies the String Comparison 
to be used. It can take the below-mentioned values: 

o 0 = vbBinaryCompare - Performs Binary Comparison(Default) 

o 1 = vbTextCompare - Performs Text Comparison 

Example 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
document.write("Line 1 :" & StrComp("Microsoft","Microsoft") & "<br />") 
document.write("Line 2 :" &StrComp("Microsoft","MICROSOFT") & "<br />") 
document.write("Line 3 :" &StrComp("Microsoft","MiCrOsOfT") & "<br />") 
document.write("Line 4 :" &StrComp("Microsoft","MiCrOsOfT",1) & "<br />") 
document.write("Line 5 :" &StrComp("Microsoft","MiCrOsOfT",0) & "<br />") 
 
</script> 
</body> 
</html> 
When you save it as .html and execute it in Internet Explorer, 
then the above script will produce the following result: 
Line 1 :0 
Line 2 :1 
Line 3 :1 
Line 4 :0 
Line 5 :1


No comments: