Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,547 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,843 people online right now. Registration is fast and FREE... Join Now!




Recognizing the F1-key

 
Reply to this topicStart new topic

Recognizing the F1-key

DenTolle
23 Aug, 2008 - 06:07 AM
Post #1

New D.I.C Head
*

Joined: 12 Aug, 2008
Posts: 2

I use the code beneath to manipulate some boxes when the F1-key is pressed.
It's not working. If I use 'Escape'-key instead of the 'F1'-key in the code it does work ... very strange ... Can anyone help me with this plzz

CODE

Private Sub txtInfoClub1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtInfoClub1.KeyPress

If e.KeyChar = Chr(Keys.F1) Then
            txtInfoNaam1.Focus()
            txtInfoClub1.Visible = False
            lblInfoClub1.Visible = False
        End If

End Sub

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Recognizing The F1-key
23 Aug, 2008 - 06:16 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
This should do what you're looking for (I tested and it worked for me)

vb

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = 112 Then
MsgBox("F1 pressed!")
End If
End Sub


Make sure you have the Forum's KeyPreview property set to True smile.gif
User is online!Profile CardPM
+Quote Post

DenTolle
RE: Recognizing The F1-key
23 Aug, 2008 - 07:20 AM
Post #3

New D.I.C Head
*

Joined: 12 Aug, 2008
Posts: 2

Thank you ... I saw the mistake now ... I used the Keypress event instead of the Keydown event ... it's working now :-)
User is offlineProfile CardPM
+Quote Post

narmer93
RE: Recognizing The F1-key
23 Aug, 2008 - 07:29 AM
Post #4

D.I.C Head
**

Joined: 13 Mar, 2008
Posts: 241



Thanked: 1 times
My Contributions
strange,ur code exactly works as this one
vb
Public Class Form1

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F1 Then
MsgBox("F1 pressed!")
End If
End Sub

End Class

that is strange
does F1=112?
that is it the differences between the 2 codes and they both work the same way and both give the same result
hmm,that is like the days then
watch this
IPB Image
it is exacltly like the days
u can type the name of the day or its number, i am right about that?
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Recognizing The F1-key
23 Aug, 2008 - 07:55 AM
Post #5

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
QUOTE(narmer93 @ 23 Aug, 2008 - 08:29 AM) *

does F1=112?


112 is the numeric value for F1.
Or
112 is how the computer reads the key.

User is offlineProfile CardPM
+Quote Post

narmer93
RE: Recognizing The F1-key
23 Aug, 2008 - 07:58 AM
Post #6

D.I.C Head
**

Joined: 13 Mar, 2008
Posts: 241



Thanked: 1 times
My Contributions
as i said,it is just liket the days,they can be typed as nums from 1 to 7 or days
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Recognizing The F1-key
23 Aug, 2008 - 08:02 AM
Post #7

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
I was just clarifying
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:00PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month