Hi all,
I have a system where a user enters values in a form, and these are checked to make sure they are within a range specified in a series of cells.
The comparison is performed like this:
I have found that using the code exactly as above does not perform the comparisons correctly, always indicating the value is out of range.
If I cast the values to CSng or CDbl then it mostly works as expected, however there are still some strange errors. For example, one of the inputs has a lower acceptable limit of 0.015. If an input of 0.6 gives an error, but 0.60 does not.
With 0.6 entered in the input box I get:
When 0.60 is entered, no error occurs.
What am I missing here?
Many thanks,
Ben.
I have a system where a user enters values in a form, and these are checked to make sure they are within a range specified in a series of cells.
The comparison is performed like this:
Code:
Dim ctl as Control
...
If ctl.value < .Cells(row, 2) Then
Debug.Print (ctl.Name & " = " & ctl.value & " and is lower than " & .Cells(row, 2))
End If
If ctl.value > .Cells(row, 3) Then
Debug.Print (ctl.Name & " = " & ctl.value & " and is higher than " & .Cells(row, 3))
End If
I have found that using the code exactly as above does not perform the comparisons correctly, always indicating the value is out of range.
If I cast the values to CSng or CDbl then it mostly works as expected, however there are still some strange errors. For example, one of the inputs has a lower acceptable limit of 0.015. If an input of 0.6 gives an error, but 0.60 does not.
With 0.6 entered in the input box I get:
Code:
sampleVolume = 0.6 is lower than 0.5
What am I missing here?
Many thanks,
Ben.