View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Think I may have screwed myself...

The form has an Activecontrol property.

Private Sub Label1_Click()
ActiveControl.Text = ActiveControl.Text & " A"
End Sub

Depending on your form/needs, you should check what the ActiveControl is.
If TypeOf ActiveControl Is MSForms.TextBox Then ..


NickHK

"rci" wrote in message
...

Thx Nick,

Well, that is good news... so, how do I find what text box (if any) has

the
current focus, and then, having that identified in a variable, how do I

use
that variable to enter text into the text box?

Seems it would have to go like this: (psydocode)

CurrentTextBox = Me.HasFocus

CurrentTextox.value = CurrentTextBox.value & NewKeyPressed


Looks simple enough... how come I doubt it is :-)

Thx!



NickHK wrote:


: Labels cannot take focus. With this, focus always remains on the text

box.

: Private Sub Label1_Click()
: TextBox1.Text = TextBox1.Text & "A"
: End Sub

: Do you mean "ActiveControl" ?

: NickHK

: "rci" wrote in message
: ...
: mmm... now I've done it.
:
: I made a keyboard, on-screen, for a touchscreen in a userform. Works
: great!
: It adds characters one at a time into a specific textbox.
:
: Oops....
:
: Now I need to add a few more text boxes... and I want it to go into

the
: text
: box with the current focus... problem is, which text box has the

current
: focus? Because as soon as I press the keyboard keys (Label objects)

it is
: *they* that have the current focus!
:
: Think I'm in a spot of trouble here :)
:
: Any ideas very much appreciated....
:
: SMS