Solved

Assign Function Keys to buttons

Posted on 2009-04-13
7
620 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

627 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