Solved

Assign hotkey to textbox for setfocus

Posted on 2001-07-16
6
252 Views
Last Modified: 2006-11-17
I design a form and there are different labels and textbox. I want to go on specific textbox by pressing Alt+F key from keyboard. How it is possible ?

Saleem
0
Comment
Question by:pak_slm
6 Comments
 
LVL 11

Expert Comment

by:Otana
ID: 6285329
a simple way is to create a command button out of sight, with a shortcut Alt+F, and then in the onclick event set:

text1.setfocus
0
 
LVL 4

Accepted Solution

by:
VincentLawlor earned 25 total points
ID: 6285350
On your main form set KeyPreview = True

In your KeyDown code on the main form

Place the following

Dim AltDown
AltDown = (Shift And vbAltMask) > 0

If KeyCode = vbKeyF Then
  If AltDown Then TextBox1.SetFocus
End If
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6285374
If you have a label describing the textbox, you can set the hotkey in the label's caption using the & character as normal. In order for this to work, you must ensure that the tab order (specified by the tabindex property for each control) places the label one place lower than the corresponding textbox:

Label1    TabIndex = 0
Text1     TabIndex = 1

Label1.Caption = "&Hello There"

In this scenario pressing Alt+H would set focus to the text box as the subsequent control in the tab order.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:pak_slm
ID: 6285431
I prefer your answer because it is code based.
Thanks.
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6285446
Your welcome
0
 
LVL 1

Author Comment

by:pak_slm
ID: 6285466
If i place a button or through label caption then i feel problem because i want more then one hotkey.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question