Funzione VBScript StrComp


❮ Riferimento completo di VBScript

La funzione StrComp confronta due stringhe e restituisce un valore che rappresenta il risultato del confronto.

La funzione StrComp può restituire uno dei seguenti valori:

  • -1 (se stringa1 < stringa2)
  • 0 (se stringa1 = stringa2)
  • 1 (se stringa1 > stringa2)
  • Null (se string1 o string2 è Null)

Sintassi

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:

  • 0 = vbBinaryCompare - Perform a binary comparison
  • 1 = vbTextCompare - Perform a textual comparison

Esempio 1

response.write(StrComp("VBScript","VBScript"))

Output:

0

Esempio 2

response.write(StrComp("VBScript","vbscript"))

Output:

-1

Esempio 3

response.write(StrComp("VBScript","vbscript",1))

Output:

0

❮ Riferimento completo di VBScript