You use comparison validators to compare the value entered by the user into a data-entry control with the value entered into another data-entry control or with a constant value. As usual for validation controls, you indicate the data-entry control to validate by setting the ControlToValidate property. If you want to compare a specific data-entry control with another data-entry control, set the ControlToCompare property to specify the control to compare with.
Instead of comparing the value of a data-entry control with another data-entry control, you can compare the value of a data-entry control to a constant value. In this case, you specify the constant value to compare with by setting the ValueToCompare property.
Don't set both the ControlToCompare and ValueToCompare properties at the same time, because they conflict. If you do, the ControlToCompare property takes precedence.
Use the Operator property to specify the type of comparison to perform. Here are the possibilities:
Equal— Checks if the compared values are equal.
NotEqual— Checks if the compared values are not equal.
GreaterThan— Checks for a greater than relationship.
GreaterThanEqual— Checks for a greater than or equal to relationship.
LessThan— Checks for a less than relationship.
LessThanEqual— Checks for a less than or equal to relationship.
DataTypeCheck— Compares data types between the value entered into the data-entry control being validated and the data type specified by the Type property.
You use the Type property to specify the data type of both comparison values. (This type is String by default, so don't forget to set this property yourself if you're comparing numbers—otherwise you'll find, for example, that a value of 150 is less than 16 in string terms.) Both values are automatically converted to this data type before the comparison operation is performed. Here are the different data types that you can use:
String— A string data type.
Integer— An integer data type.
Double— A double data type.
Date— A date data type.
Currency— A currency data type.
There's a comparison validator next to the second text box in Figure 18.2. This is the validator that compares class rank with class size and makes sure that the users' rank is less than or equal to their class size.