Solved

Assign Function Keys to buttons

Posted on 2009-04-13
7
614 Views
Last Modified: 2012-05-06
I have a form with 3 stopwatches on it.  Each one has a stop/start button.
I need to map function keys to each of the stop/start buttons.  
F1 would go to the first stop/start button, F3 would go to the second stop/start button, F5 would go to the 3rd stop/start button.
The form will be the active form, but it is likely that nothing will be selected on the form.
How would I map these function keys to the buttons?
Please provide code samples.  When I click on links my IE crashes.
Thanks
0
Comment
Question by:Sheritlw
  • 4
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24128584
Hi, you can do something like this:
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        Select Case e.KeyCode

            Case Keys.F1

                ' call the 1st

            Case Keys.F3

                ' call the 2nt

            Case Keys.F5

                ' call the 3rd

        End Select

    End Sub
 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.KeyPreview = True

    End Sub

Open in new window

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24128590
You can use IsRunning property to identify if the stopwatcher is running and start or stop it.

        Dim myStopwatch As New Stopwatch

        If myStopwatch.IsRunning Then

            myStopwatch.Stop()

        Else

            myStopwatch.Reset()

            myStopwatch.Start()

        End If

Open in new window

0
 

Author Comment

by:Sheritlw
ID: 24128620
Thank you again, jpaulino.  
You are great!!!!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Closing Comment

by:Sheritlw
ID: 31569429
Excellent as always!
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24128644
Glad I could help!
0
 

Author Comment

by:Sheritlw
ID: 24128661
Do you want to answer a question about laying out windows forms in a MDI app. Users will select from a list, not from a menu bar.
If you want to, I will post the question now.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24128684
Ok, then create a new question and I will take a look.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now