View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default User Form Input Question

I'll withhold comment about your overall design, about which I will
give you the benefit of the doubt that there is some reason for not
using the keyboard and using SendKeys. Moreover, you'll find things
much simpler if you give meaningful names to the label controls. E.g.,
instead of Label12, use LabelLetterS or something.

I would create a module-scoped Boolean named bCapsLock and set and
test that. E.g,.

Private bCapsLock As Boolean

Private Sub Label2_Click()
Dim LBL As MSForms.Control
bCapsLock = Not bCapsLock
For each LBL In Me.Controls
If typeof LBL is MSForms.label then
if bCapsLock Then
LBL.Caption = UCase(LBL.Caption)
else
lbl.caption = Lcase(LBL.Caption)
end if
end if
next lbl
End Sub

' example letter
Private Sub Label3_Click()
If bCapsLock Then
SendKeys "B"
Else
SendKeys "b"
End If
End Sub


Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]



On Sat, 5 Dec 2009 07:48:01 -0800, brichard429
wrote:

I am designing a User Form to allow someone to enter their name. There is no
keyboard only a mouse for input. I have the alphabet represented by using
Label Objects. Each lable has the appropriate caption A,B C etc. I use the
SendKeys method to enter letters in the Text Box when the appropriate lable
is clicked. Example:
Private Sub Label3_Click()
SendKeys ("b")
End Sub

I also have a lable to set capslock:

Private Sub Label2_Click()
SendKeys ("{CAPSLOCK}")
End Sub

I would like the caption on each all of the letter labels to change with
the state of Capslock. In other words when CapsLock is on the label would
read "A" and when CapsLock is off the lable would read "a" etc. for all the
letters. I'm sure there's a way to do this using the vbKeyCapital constant
but I don't know how.