[Gambas-user] disallow characters in TextBox

Charlie Reinl Karl.Reinl at ...9...
Thu Apr 9 14:42:40 CEST 2009


Am Donnerstag, den 09.04.2009, 12:23 +0100 schrieb Joshua Higgins:
> Hi,
> 
> Is it possible to disallow certain characters from being entered in a
> TextBox?
> 
> I'm splitting the data from the textbox and don't want the user to type in
> the character (~) that is being used to split.
> 
> Thanks.

Salut,

here the KeyPress Event from TextBox1 looks for valid Keys (this is out
of a gambas1 project)

PUBLIC SUB TextBox1_KeyPress()
    IF key.Code >= 48 AND key.Code <= 57 THEN
    ELSE IF key.Code = key.BackSpace THEN
    ELSE IF key.Code = key.Delete THEN
    ELSE
        STOP EVENT
    ENDIF
END

So, you have to write something like :
(this is not tested) 
IF key.Code = "~" THEN
        STOP EVENT
ENDIF

-- 
Amicalment
Charlie





More information about the User mailing list