VBScript StrComp function
StrComp function compares two strings and returns a value representative of the comparison result.
StrComp function can return the following values:
- 1 (if string1 <string2)
- 0 (if string1 = string2)
- 1 (if string1> string2)
- Null (if string1 or string2 is Null)
grammar
StrComp(string1,string2[,compare])
参数 | 描述 |
---|---|
string1 | 必需。字符串表达式。 |
string2 | 必需。字符串表达式。 |
compare | 可选。规定要使用的字符串比较类型。默认是 0。 可采用下列的值:
|
Example 1
document.write(StrComp("VBScript","VBScript"))
Output:
0
Output:
0
Example 2
document.write(StrComp("VBScript","vbscript"))
Output:
-1
Output:
-1
Example 3
document.write(StrComp("VBScript","vbscript",1))
Output:
0
Output:
0
Complete VBScript Reference