How do I limit a variable to only 1 character?

Continuing the discussion from Post and Attachment Guidelines:

Hello. In the appinventor is it possible to limit a variable to only 1 character?
If so. Right after filling in, can the cursor jump to the next field?

Hello Denilson

The User would not be filling in a variable, that would be a TextBox. So, the code needs to check the length of the text/number input. A bit ugly......

OneChar.aia (3.5 KB)

1 Like

You could also use this extension from @Taifun

https://puravidaapps.com/textbox.php

1 Like

If you are limiting to one character, you are also probably limiting to certain characters, right?

So just use a little List Picker, and do the RequestFocus in the AfterSelected event.

In other words. You cannot do this with a text box.
I built your code but it didn't work here. Can you send me the app, please? [mod edit - personal info removed]

Did you try Taifun's extension?

Yes, you can do it with a value in a textbox, which is what the code demonstrates.

Hi, Peter, I have taifun's extention, but cannot figure how to limit input in text box to one charactor.

Eddie B

Try this way

3 Likes

Good Day From the the land of Oz. Dora!
Wonderful! yes, it works. Originally I put the wrong segment block in and everything locked up, then after correcting it with the right one! BINGO! worked like a charm! I Taifun produces some great extensions, so will have to 'donate' to show my appreciation. As for you, Dora, beautiful picture of you! OK, now I have to go through all my one-character text blocks and code them all!
Thanks and regards
Eddie B

2 Likes

Hi again, though the extension worked, there was an issue with data in the cell. I noted that that the extension worked almost exactly like my original, using the notifier. I also needed to clear other cells and reset the cursor to the original cell. So redid my blocks as per this pic and seems to work exactly as I require.

Eddie