VBScript StrComp-functie

Definitie en gebruik

De functie StrComp kan twee strings vergelijken en een waarde retourneren die het resultaat van de vergelijking aangeeft.

De functie StrComp kan de volgende waarden retourneren:

  • -1 (如果 string1 < string2)
  • -1 (if string1 < string2)
  • 0 (if string1 = string2)
  • 1 (if string1 > string2)

Null (if string1 or string2 is Null)

Syntax
StrComp(string1,string2[,compare]) Parameters
Description string2
string1 string2
Required. String expression.

compare

Optional. Specifies the string comparison to use. Default is 0

  • Values that can be used:
  • 0 = vbBinaryCompare - Execute binary comparison

1 = vbTextCompare - Execute text comparison

Example

Example 1

Uitvoer:

0

Example 2

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

Uitvoer:

-1

Example 3

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

Uitvoer:

0