There are two functions for comparing VARIANTs. One comes from the COM team, called VarCmp. Assuming a successful comparison, it returns
| Comparison | Return value |
|---|---|
| Less than | 0 = VARCMP_LT |
| Equal to | 1 = VARCMP_EQ |
| Greater than | 2 = VARCMP_GT |
This is consistent with the other VarXxx functions.
On the other hand, the VariantCompare function comes from the shell, and it returns
| Comparison | Return value |
|---|---|
| Less than | −1 |
| Equal to | 0 |
| Greater than | +1 |
Yuck.
So be careful which one you’re calling and how you’re testing the result.
0 comments