CompareMode Property

 

Description

 

Sets or returns the comparison mode for comparing string keys in a Dictionary object.

 

PowerBASIC Syntax

 

PROPERTY GET CompareMode () AS LONG

PROPERTY SET CompareMode (BYVAL nCompare AS LONG)

 

Arguments

 

nCompare

LONG. A value representing the comparison mode. Acceptable values are 0 (Binary), 1 (Text), 2 (Database). Values greater than 2 can be used to refer to comparisons using specific Locale IDs (LCID).

 

Remarks

 

An error occurs if you try to change the comparison mode of a Dictionary object that already contains data.

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM pDic AS IDictionary

DIM vKey AS VARIANT

DIM vItem AS VARIANT

 

' Create an instance of the Dictionaty object

pDic = NEWCOM "Scripting.Dictionary"

' Add some key/item pairs to the dictionary

vKey = "a" : vItem = "Athens"

pDic.Add vKey, vItem

vKey = "b" : vItem = "Belgrade"

pDic.Add vKey, vItem

vKey = "c" : vItem = "Cairo"

pDic.Add vKey, vItem

' Set the comparison mode to text

pDic.CompareMode = %CompareMethod_TextCompare

vKey = "B" : vItem = "Baltimore"

' Add method fails in this line because the

' letter b already exists in the dictionary

pDic.Add vKey, vItem

 

Valid XHTML 1.0 Transitional