Solved

Assign Function Keys to buttons

Posted on 2009-04-13
7
615 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

25 Experts available now in Live!

Get 1:1 Help Now