Funzione StrComp di VBScript
Definizione e uso
La funzione StrComp può confrontare due stringhe e restituire un valore che rappresenta il risultato del confronto.
La funzione StrComp può restituire i seguenti valori:
- -1 (如果 string1 < string2)
- -1 (se string1 < string2)
- 0 (se string1 = string2)
- 1 (se string1 > string2)
Null (se string1 o string2 sono Null)
Sintassi
StrComp(string1,string2[,compare]) | Parametro |
---|---|
Descrizione | string2 |
string1 | string2 |
Obbligatorio. Espressione di stringa. |
compare Opzionale. Specifica il tipo di confronto di stringa da utilizzare. Predefinito è 0. Optional. Specifies the string comparison to use. Default is 0
|
1 = vbTextCompare - Esegue confronto testuale
Esempio
Esempio 1
Output:
0
Esempio 2
document.write(StrComp("VBScript","vbscript"))
Output:
-1
Esempio 3
document.write(StrComp("VBScript","vbscript",1))
Output:
0