Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Assign Function Keys to buttons

Posted on 2009-04-13
7
Medium Priority
?
624 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 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