Hàm StrComp của VBScript
❮ Tham khảo VBScript đầy đủ
Hàm StrComp so sánh hai chuỗi và trả về một giá trị đại diện cho kết quả so sánh.
Hàm StrComp có thể trả về một trong các giá trị sau:
- -1 (nếu chuỗi1 < chuỗi2)
- 0 (nếu chuỗi1 = chuỗi2)
- 1 (nếu chuỗi1 > chuỗi2)
- Null (nếu string1 hoặc string2 là Null)
Cú pháp
StrComp(string1,string2[,compare])
Parameter | Description |
---|---|
string1 | Required. A string expression |
string2 | Required. A string expression |
compare | Optional. Specifies the string comparison to use.
Default is 0 Can have one of the following values:
|
ví dụ 1
response.write(StrComp("VBScript","VBScript"))
Output:
0
Ví dụ 2
response.write(StrComp("VBScript","vbscript"))
Output:
-1
Ví dụ 3
response.write(StrComp("VBScript","vbscript",1))
Output:
0
❮ Tham khảo VBScript đầy đủ