[Gambas-user] ValueBox value validation

Caveat Gambas at ...1950...
Thu Jan 19 17:17:19 CET 2012


Oh, looks like you're right (I have Gambas3, rev 4409).  I just added a
ValueBox to an existing Form and put in the following code:

Public Sub ValueBox1_LostFocus()

  Print "ValueBox: Oh no, I lost my focus!  I'm sure it's around here
somewhere..."

End

Public Sub cbxLockingSystem_LostFocus()

  Print "ComboBox: Oh no, I lost my focus!  I'm sure it's around here
somewhere..."

End

The ComboBox fires off LostFocus quite happily, but the ValueBox never
does.

I wanted to check the docs to see if there was anything funny about
ValueBox (perhaps doesn't support LostFocus) but the component doesn't
appear in the gb.qt4 docs...
http://gambasdoc.org/help/comp/gb.qt4?v3&show

Guess it's over to the devs...

Kind regards,
Caveat

On Thu, 2012-01-19 at 15:41 +0000, John Rose wrote:
> 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 at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list