Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

VBScript StrComp Function

VBScript StrComp Function


VBScript reference manual Complete VBScript Reference Manual


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

The StrComp function can return the following values:

Syntax

StrComp(string1,string2[,compare])

Parameters Description
string1 Required. A string expression.
string2 Required. A string expression.
compare Optional. Specifies the type of string comparison to use. The default is 0.

The following values can be used:

  • 0 = vbBinaryCompare - Performs a binary comparison
  • 1 = vbTextCompare - Performs a textual 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