O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Dictionary.CompareMode Property

Data Type

Long

Description

Sets or returns the mode used to compare the keys in a Dictionary object.

Rules at a Glance

  • CompareMode can be set only on a dictionary that doesn’t contain any data.

  • The CompareMode property can have either of the following two values:

    0, Binary

    This is the default value. It compares the keys with a string byte-per-byte to determine whether a match exists.

    1, Text

    Uses a case-insensitive comparison when attempting to match keys with a string.

    In addition, the value of CompareMode can be greater than 2, in which case it defines the locale identifier (LCID) to be used in making the comparison.

Programming Tips and Gotchas

  • You need to explicitly set the CompareMode property only if you do not wish to use the default binary comparison mode.

  • The Scripting Runtime type library defines constants (BinaryCompare and TextCompare) that can be used in place of their numeric equivalents. You can do this in one of three ways. You can define the constants yourself by adding the following code to your script:

    Const BinaryCompare = 0
    Const TextCompare = 1

    You can also use the equivalent vbBinaryCompare and vbTextCompare constants that are defined in the VBScript library.

    Finally, if you’re an ASP programmer, you can use the METADATA directive to access the Scripting Runtime type library; if you’re developing a Windows Script Host script, you can include the following line in a Windows Script Host (.wsf ) file in order to access the constants from the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required