Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default User Form Input Question

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.
--
Bernie
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default User Form Input Question

I would not use SendKeys to do what you are doing... instead, I would just
assign the values to the TextBox directly. I would also use the Label's
Caption property to make the assignment. Here is a start of the code you
would need to do this...

' This is the routine to toggle the Label
' captions between upper and lower case...
' Label2 assumed because you posted that
Private Sub Label2_Click()
Dim C As Control
For Each C In Me.Controls
If TypeOf C Is MSForms.Label Then
If C.Caption < "CapsLock" Then
If C.Caption = UCase(C.Caption) Then
C.Caption = LCase(C.Caption)
Else
C.Caption = UCase(C.Caption)
End If
End If
End If
Next
End Sub

' Each letter/number/symbol label would look like
' this except for the Label name in the assigment
Private Sub Label1_Click()
TextBox1.SelText = Label1.Caption
End Sub

' Each letter/number/symbol label would look like
' this except for the Label name in the assigment
Private Sub Label3_Click()
TextBox1.SelText = Label3.Caption
End Sub

etc....

Note that you can omit the comments in your actual code, they are there for
instruction purposes only.

--
Rick (MVP - Excel)


"brichard429" wrote in message
...
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.
--
Bernie


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default User Form Input Question

I should have mentioned... if you have other Labels on your UserForm that
are not "typable" symbols, then you will have to protect their captions from
being upper/lower cased when the CapsLock key is clicked. Right now I have
this line protecting the CapsLock label...

If C.Caption < "CapsLock" Then

To expand this for other possible Labels you might have, it would change
like this...

If C.Caption < "CapsLock" And C.Caption < "Delete" And _
C.Caption < "Insert" And C.Caption < "Home" Then

Just keep And'ing additional tests as needed. Also note that the Label's
caption being tested for (inside the quotes) must match the actual Label's
caption exactly (letter casing, spaces).

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
I would not use SendKeys to do what you are doing... instead, I would just
assign the values to the TextBox directly. I would also use the Label's
Caption property to make the assignment. Here is a start of the code you
would need to do this...

' This is the routine to toggle the Label
' captions between upper and lower case...
' Label2 assumed because you posted that
Private Sub Label2_Click()
Dim C As Control
For Each C In Me.Controls
If TypeOf C Is MSForms.Label Then
If C.Caption < "CapsLock" Then
If C.Caption = UCase(C.Caption) Then
C.Caption = LCase(C.Caption)
Else
C.Caption = UCase(C.Caption)
End If
End If
End If
Next
End Sub

' Each letter/number/symbol label would look like
' this except for the Label name in the assigment
Private Sub Label1_Click()
TextBox1.SelText = Label1.Caption
End Sub

' Each letter/number/symbol label would look like
' this except for the Label name in the assigment
Private Sub Label3_Click()
TextBox1.SelText = Label3.Caption
End Sub

etc....

Note that you can omit the comments in your actual code, they are there
for instruction purposes only.

--
Rick (MVP - Excel)


"brichard429" wrote in message
...
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.
--
Bernie



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
user form input Brian Matlack[_84_] Excel Programming 2 May 23rd 06 09:27 PM
VBA Question: User Form and input masks MarianneR[_5_] Excel Programming 2 October 13th 05 08:48 PM
VBA Question: User Form and input masks MarianneR[_4_] Excel Programming 0 October 13th 05 07:41 PM
User Input Form Beth[_6_] Excel Programming 2 May 13th 04 01:23 AM
Help with a User Input Form Cody Dawg[_2_] Excel Programming 3 October 9th 03 10:08 PM


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"