Solved

Assign Function Keys to buttons

Posted on 2009-04-13
7
616 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 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