YouTip LogoYouTip

Func Strcomp

VBScript StrComp Function

VBScript StrComp Function

-- Learn not just technology, but also dreams!

VBScript Tutorial VBScript Examples VBScript Keywords Deep Dive Computer Scripting Language Computer Programming Web Service Computer Hardware Development Tools Software Scripting Programming Languages

VBScript StrComp Function


VBScript Reference Manual Complete VBScript Reference Manual


StrComp function compares two strings and returns a value representing the comparison result.

StrComp function can return the following values:

  • -1 (if string1 < string2)
  • 0 (if string1 = string2)
  • 1 (if string1 > string2)
  • Null (if string1 or string2 is Null)

Syntax

StrComp(string1,string2[,compare])
Parameter Description
string1 Required. A string expression.
string2 Required. A string expression.
compare Optional. Specifies the type of string comparison to use. Default is 0. Can be one of the following values:
  • 0 = vbBinaryCompare - Perform a binary comparison
  • 1 = vbTextCompare - Perform a text comparison

Example 1

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

Output:

0

Example 2

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

Output:

-1

Example 3

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

Output:

0

VBScript Reference Manual Complete VBScript Reference Manual

← Func StringFunc Space β†’