[Gambas-user] Check on entered number having more than 6 digits not working
John Rose
john.aaron.rose at ...626...
Sat Aug 11 16:51:35 CEST 2012
I'm trying to validate an entered Latitude value as having a maximum of
6 digits after the decimal point. Sometimes it doesn't work. In the case
below, it is 48.590278. This should be valid, but the
'Message.Info("More than 6 decimal digits - try again")' line is being
executed. As you can see from the Print statements, the check should be
OK. Am I missing something really obvious?
Public Sub ValueBoxLatitude_LostFocus()
Dim latitude As Float
Dim f As Float
Dim g As Float
If IsNull(Last.Value) Then Return
latitude = Last.Value
If latitude < -90 Or latitude > 90 Then
Message.Info("Must be between -90 and +90 - try again")
Last.SetFocus()
Stop Event
End If
f = latitude * 1000000
g = CFloat(CInt(f))
Print "f=" & f
Print "g=" & g
If f <> g Then
Message.Info("More than 6 decimal digits - try again")
Last.SetFocus()
Stop Event
End If
f=48590278
g=48590278
--
Regards,
John
+44 1902 331266
+44 7894 211434
More information about the User
mailing list