Re: Text entry limitation

Marnaud <[email protected]>
Newsgroups gmane.comp.lang.realbasic.user
Message-ID <[email protected]>
Le 18 août 2017 à 18:17 du soir, Jean-Luc Arnaud <[email protected]> a écrit:
> I finally coded that in the KeyDown event of a TextField control:
> 
> Select Case Key
>   
> Case "I","V","X","L","C","D","M", Chr(13), Chr(3), Chr(127)
>   Return False
>   
> Case Chr(9)
>   Décimal_TextField.SetFocus
>   Return True
>   
> Case Is>=Chr(32)
>   Return True
>   
> End Select
> 
> This matches exactly my need (except for Drag/Drop and Paste).
> 

I usually do something like that. The notable difference being I use Select case Asc(Key) instead of comparing against Chr (this is the other way around, but I do like that because the language reference state that Chr returns character as ASCII values and I have seen cases where the equality wasn’t true).

As I understand, you’re trying to only accept roman characters, right?

Why do you handle the chr(9) like this? The tab key should just work if you return false (and don’t forger if the user is actually typing Shift-Tab to move the focus to the previous field!)

Also, Is>=Chr(32) is redundant with Chr(13) and chr(3) returning false. I’m just saying that to improve the piece of code above.

Regards


To unsubscribe, email [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.