I have a problem with validating a user-entered value in a ValueBox. I've
tried LostFocus & Leave and neither seems to do the validation i.e. no
message box appears for incorrect values. So I thought that I would try
Change, even though the documentation says that it is raised on each
character typed in (rather than at the end of typing in the changes to the
value) which would not be any good. However, I'm not able to use the Change
event (i.e. not in popup menu for event and has no effect at runtime) for a
Valuebox: looks like a bug.  I've tried using KeyRelease, but that applies
to each character change, so that it rejects the value as each character is
entered.  Code fragment is:
Public Sub ValueBoxLatitude_Change()
  Dim latitude As Float
  Dim i As Integer
  Print "Latitude Validation"
  latitude = Last.Value
  If latitude < -90 Or latitude > 90 Then
    Message.Info("Must be between -90 and +90 - try again")
    Last.SetFocus
    Stop Event
  Endif
  i = CInt(latitude * 1000000)
  Print "CInt(latitude * 1000000)=", i
  If (latitude * 1000000) - CFloat(i) <> 0.0 Then
    Message.Info("More than 6 decimal digits - try again")
    Last.SetFocus
    Stop Event
  Endif
End

PS what event should this validation be under?
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to