Name

Dictionary.CompareMode Property

Property Data Subtype

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 & 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 any 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 ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.