Software Development optimize

Understand how to use VB6's UseMnemonic Property

If you don't want the VB6 Label control to treat ampersands in the usual manner, then learn how to use the control's UseMnemonic property to get the result you want.

VB6's Label control lets you define an access key by including an ampersand (&) in the control's Caption property. For example, a Caption of &Name will display "Name" with the N underlined, and will also define [Alt]N as the access key for that control. If you need to include an actual ampersand in the caption, you should include two ampersands. Thus, the caption "Scotch && Soda" displays as "Scotch & Soda".

However, what if you do not want the Label control to treat ampersands this way? For instance, suppose you are filling Label controls with text from a database and have no control over the ampersands in this text. All you need to do is simply set the control's UseMnemonic property to False and the control will not treat ampersands in any special way.

Miss a tip?

Check out the Visual Basic archive, and catch up on the most recent editions of Peter Aitken's column.

Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!

0 comments