1-1 Comparison: isValueEqualOrGreater
Reference Page: Comparison Rules
Automatic Comparison Rules
Relationship: One-to-One / Rule: Is Value Equal Or Greater
Definitions
Supported data types: String, Number, Date
Comparison of values of different data types always returns False.
Comparison of values of unsupported data types always returns False.
Data type: String
Strings are compared based on total length and encoding of each character.
Two strings are considered equal if they have equal length (same number of characters) AND all characters, compared one by one, were equal.
A string of longer length is always considered greater. Comparison of two strings is performed character by character up to the first character that differs. The string with the greater character in that position is considered greater.
Data type: Number
Numeric values are considered equal if there is no difference (near-zero-difference) between them (matters for floating point numbers with precision loss).
A greater value is considered greater than a smaller one. All negative numbers are less than zero and all positive numbers. Thus, -1 is less than 100; -100 is less than -1.
The floating-point value NaN (not a number) is greater than any other numeric value and is equal to itself.
Data type: Date
Date/time values are compared per component values: Year, Month, Day, Hour, Second.
Two dates are considered equal if there is zero seconds difference between them.
A later date is considered greater than an earlier one. A date with a greater month but lesser year is considered less, and so forth.
Implementation
Public Function isValueEqualOrGreater(ByVal sActualValue, ByVal sExpectedValue, ByVal sFormat)
Dim intRC
If Not isSameFormat(sActualValue, sExpectedValue, sFormat) Then
isValueEqualOrGreater = False
Exit Function
End If
Select Case UCase(sFormat)
Case "NUMBER"
If CDbl(sActualValue) >= CDbl(sExpectedValue) Then
isValueEqualOrGreater = True
Else
isValueEqualOrGreater = False
End If
Case "DATE"
If DateDiff("s", CDate(sActualValue), CDate(sExpectedValue)) <= 0 Then
isValueEqualOrGreater = True
Else
isValueEqualOrGreater = False
End If
Case "STRING"
intRC = StrComp(sActualValue, sExpectedValue)
If (intRC = 0) OR (intRC = 1) Then
isValueEqualOrGreater = True
Else
isValueEqualOrGreater = False
End If
Case Else
isValueEqualOrGreater = False
End Select
End Function
Test Code
Log.Message("1-1 Comparison: isValueEqualOrGreater")
boolRC = isValueEqualOrGreater("zzzzaaaa", "aaaazzzz", "String")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater("abc", "ab", "String")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater("abc", "ab ", "String")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater(1, 0, "Number")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater(dblNearlyZero, 0, "Number")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater(0, -1, "Number")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater(-1, -10, "Number")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
sValue1 = CDate("1/1/2002")
sValue2 = CDate("01/01/01")
boolRC = isValueEqualOrGreater(sValue1, sValue2, "DATE")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
sValue1 = CDate("1/1/2050")
sValue2 = CDate("31/12/2050")
boolRC = isValueEqualOrGreater(sValue1, sValue2, "DATE")
If boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater(1, 1.0, "Number")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater("1", "1.0", "String")
If boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
boolRC = isValueEqualOrGreater(1, 1.0, "Double")
If boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
sValue1 = 1
sValue2 = 1+dblNearlyZero
boolRC = isValueEqualOrGreater(sValue1, sValue2, "Number")
If boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
sValue1 = 1+dblNearlyZero/10
sValue2 = 1
boolRC = isValueEqualOrGreater(sValue1, sValue2, "Number")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
sValue1 = CDate("01/01/01")
sValue2 = CDate("01/01/2001")
boolRC = isValueEqualOrGreater(sValue1, sValue2, "DATE")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If
sValue1 = CDate("01/01/01")
sValue2 = CDate("1/1/2001")
boolRC = isValueEqualOrGreater(sValue1, sValue2, "DATE")
If Not boolRC Then
Log.Error("isValueEqualOrGreater failed")
End If

