Textbox to textbox

kavka

Member
Licensed User
Hello!

Help me solve the following problem:

I have two textboxes. The number of digits in one textbox is two. When I enter the second digit in the first textbox I want that the second textbox gets focused. is that possible?

:sign0085:

kavkaa
 

willisgt

Active Member
Licensed User
Sure, it's possible.

The most logical thing to do would be to catch this with the KeyPress event. There's a problem, though - the KeyPress event gets raised *before* the key you pressed actually gets added to the textbox. At least that's the behavior on my desktop and device.

So I've been using a little workaround that involves a timer. Create your form, textbox1, textbox2, and timer1.

In AppStart:

B4X:
timer1.interval = 100   ' thats 100 milliseconds
timer1.enabled = false

and then:

B4X:
sub textbox1_KeyPress( key )
   timer1.enabled = true
end sub

sub timer1_Tick
   if StrLength( textbox1.text) >= 2 then textbox2.Focus
   timer1.enabled = false
end sub

It comes close to a cheezy hack, but hey, it works for me.

Gary

:sign0025:
 

willisgt

Active Member
Licensed User
Cheezy hackers of the world, unite!

:sign0151:
 

kavka

Member
Licensed User
agraham, can you help me out with this missing events. Do I just copy those three files in the library directory and that is that?
 

agraham

Expert
Licensed User
Longtime User
Sounds like you need to learn how to use libraries. You should have downloaded the latest ControlEvents version from either Post #5 (.Net 2.0) or #6 (.NET1.0) from that thread. One of those files is a help file, the chm, the library is the dll - stick the help and the library in the Anywhere Software Libraries folder. Ignore and discard the cs file - you don't need it.

Restart B4PPC - Desktop. The ControlEvents help should now show under Help - read it and the Main help about libraries.
 
Top