ฟังก์ชั่น VBScript StrComp
ฟังก์ชั่น StrComp เปรียบเทียบสองสตริงและผลตอบแทนที่คุ้มค่าเป็นตัวแทนของผลการเปรียบเทียบ
ฟังก์ชั่น StrComp สามารถกลับค่าต่อไปนี้:
- 1 (ถ้า string1 <string2)
- 0 (ถ้า string1 = string2)
- 1 (ถ้า string1> string2)
- null (ถ้า string1 string2 หรือเป็นโมฆะ)
ไวยากรณ์
StrComp(string1,string2[,compare])
参数 | 描述 |
---|---|
string1 | 必需。字符串表达式。 |
string2 | 必需。字符串表达式。 |
compare | 可选。规定要使用的字符串比较类型。默认是 0。 可采用下列的值:
|
ตัวอย่างที่ 1
document.write(StrComp("VBScript","VBScript"))
Output:
0
Output:
0
ตัวอย่างที่ 2
document.write(StrComp("VBScript","vbscript"))
Output:
-1
Output:
-1
ตัวอย่างที่ 3
document.write(StrComp("VBScript","vbscript",1))
Output:
0
Output:
0
อ้างอิง VBScript สมบูรณ์