Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Caps

Status
Not open for further replies.

baileybelle

Technical User
Jul 22, 2002
10
US
In the KeyPress event of a text box I would like to force capitalization. I am using the following w/out success:

nKeyCode=asc(upper(chr(nKeyCode)))

What would the proper syntax be to accomplish this?

Also. does anyone know how to highlight the contents of a text box when it recieves focus?

thanks

bailey
 
Set the format property of your text box to !K

The ! Will force upper case
The K Will select (Highlight) the text on get focus

Read the help for format property for more info

Walid Magd
Engwam@Hotmail.com
 
baileybelle

Another way might be:

= CAPSLOCK(.T.) && Will turn on your Caps Lock key. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Bailey..

1. In the GotFocus event of the textbox.. enter the code..
= CAPSLOCK(.T.)

2. You can generalise in the start of the main.PRG, you can put the code..
=CAPSLOCK(.t.)
This will make the Keyboard set with CAPSLOCK on

However, the suers can press the capslock key and change it. If you do not want that behaviour in your fields...
you can enter in the FORMAT property of the textboxes..
!
This will convert any lowercase input also to upper case.

3. IN places likle email address acceptance..in a textbox, you would want a lower case.
In the GotFocusEvent.. put the code..
=CAPSLOCK(.f.)
in the lostfocus event.. put the code..
=CAPSLOCK(.t.)

This should solve your problem. Keypress evet is not the right place.

3. Now to get the whole text as selected text in any text box couled with the CAPS LOCK..
enter in the FORMAT property..
K!
When the user types a letter it will replace all the selected text.

4. However if what you meant by highlighting a textbox getting a distinct color.. rather than selecting all the text.. then
in the GOtFocusEvent add the following code..
This.BackColor = RGB(255,192,192)
in the LostFocusEvent
This.BackColor = RGB(255,255,255)

The color codes can be suitably changed to your liking.
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
Happy New Year [bigears] [party] [2thumbsup]

 
IMHO

The capslock(.T) is a terrible suggestion. You are assuming that your program is the only one operating on the user's computer and that he/she is not going to switch to another program.

Again IMHO, never change a setting that is not applicable to only your program unless the user through some sort of dialog box has asked you to set an option. It is not your computer it is the users computer.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top