AnnaHansen
Board Regular
- Joined
- Oct 27, 2014
- Messages
- 58
I'm wrestling with odd behavior from vba.
I am trying to compare two numbers which are both converted to double type using cdbl() before comparison.
If greater, then do X. (else nothing)
However, when the two values are equal (in this case, 60604.02), the statement is evaluating true and doing X when I want it to not do X.
I'm baffled as to why this would be. I have found several explanations online that have to do with comparing strings and numbers, but nothing with odd results comparing two numbers.
<code>
Dim dblMyNum As Double
Dim dblLow As Double
dblLow = CDbl(txtBalTo.Value)
For i = 1 To lngCntAll
dblMyNum = CDbl(varFrame(i, 1))
If dblMyNum > dblLow Then
...
End If
Next i
</code>
I am trying to compare two numbers which are both converted to double type using cdbl() before comparison.
If greater, then do X. (else nothing)
However, when the two values are equal (in this case, 60604.02), the statement is evaluating true and doing X when I want it to not do X.
I'm baffled as to why this would be. I have found several explanations online that have to do with comparing strings and numbers, but nothing with odd results comparing two numbers.
<code>
Dim dblMyNum As Double
Dim dblLow As Double
dblLow = CDbl(txtBalTo.Value)
For i = 1 To lngCntAll
dblMyNum = CDbl(varFrame(i, 1))
If dblMyNum > dblLow Then
...
End If
Next i
</code>