14-09-19, 03:38 AM
السلام عليكم اعرف اني عذبتكم بكثرة الاسئلة
واليوم بعذبكم زيادة
امزح ...
كان لدي كود عندما اضغط على ESC يخرج من البرنامج
هل يوجد اخر عندما اضغط زر F11 يحدث امر او مسج بوكس
انتظر الرد
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.Alt Then
MsgBox("Alt")
ElseIf e.KeyCode = Keys.ShiftKey Then
MsgBox("ShiftKey")
ElseIf e.KeyCode = Keys.A Then
MsgBox("A")
ElseIf e.KeyCode = Keys.Cancel Then
MsgBox("Cancel")
ElseIf e.KeyCode = Keys.ControlKey Then
MsgBox("Control")
ElseIf e.KeyCode = Keys.Enter Then
MsgBox("Enter")
ElseIf e.KeyCode = Keys.Escape Then
MsgBox("Escape")
ElseIf e.KeyCode = Keys.F1 Then
MsgBox("F1")
ElseIf e.KeyCode = Keys.F11 Then
MsgBox("hELLO")
ElseIf e.KeyCode = Keys.Space Then
MsgBox("Space")
ElseIf e.KeyCode = Keys.Back Then
MsgBox("BackSpace")
End If
End Sub
(14-09-19, 03:52 AM)ابراهيم ايبو كتب : [ -> ]السلام عليكم اخي الكريمتفضل هذا الكود في حدث KeyDown هذه محموعة من المفاتيحبنفس الطريقة ضع المفتاح الذي تريد وبدل اظهار رسالة ضع الكود الذي تريد تنفيذهكود :
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.Alt Then
MsgBox("Alt")
ElseIf e.KeyCode = Keys.ShiftKey Then
MsgBox("ShiftKey")
ElseIf e.KeyCode = Keys.A Then
MsgBox("A")
ElseIf e.KeyCode = Keys.Cancel Then
MsgBox("Cancel")
ElseIf e.KeyCode = Keys.ControlKey Then
MsgBox("Control")
ElseIf e.KeyCode = Keys.Enter Then
MsgBox("Enter")
ElseIf e.KeyCode = Keys.Escape Then
MsgBox("Escape")
ElseIf e.KeyCode = Keys.F1 Then
MsgBox("F1")
ElseIf e.KeyCode = Keys.F11 Then
MsgBox("hELLO")
ElseIf e.KeyCode = Keys.Space Then
MsgBox("Space")
ElseIf e.KeyCode = Keys.Back Then
MsgBox("BackSpace")
End If
End Sub
جار التجربة
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.F11 Then
MsgBox("F11 key pressd ")
End If
End Sub
Public Sub FuncKeysModule(ByVal value As Keys)
'Check what function key is in a pressed state, and then perform the corresponding action.
Select Case value
Case Keys.F1
'Add the code for the function key F1 here.
MessageBox.Show("F1 pressed")
Case Keys.F2
'Add the code for the function key F2 here.
MessageBox.Show("F2 pressed")
Case Keys.F3
'Add the code for the function key F3 here.
MessageBox.Show("F3 pressed")
Case Keys.F4
'Add the code for the function key F4 here.
MessageBox.Show("F4 pressed")
Case Keys.F5
'Add the code for the function key F5 here.
MessageBox.Show("F5 pressed")
Case Keys.F6
'Add the code for the function key F6 here.
MessageBox.Show("F6 pressed")
Case Keys.F7
'Add the code for the function key F7 here.
MessageBox.Show("F7 pressed")
Case Keys.F8
'Add the code for the function key F8 here.
MessageBox.Show("F8 pressed")
Case Keys.F9
'Add the code for the function key F9 here.
MessageBox.Show("F9 pressed")
Case Keys.F10
'Add the code for the function key F10 here.
MessageBox.Show("F10 pressed")
Case Keys.F11
'Add the code for the function key F11 here.
MessageBox.Show("F11 pressed")
Case Keys.F12
'Add the code for the key F12 here
MessageBox.Show("F12 pressed")
Case Keys.Enter
MessageBox.Show("Enter pressed")
End Select
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyValue = Keys.F1 Or Keys.F2 Or Keys.F3 Or Keys.F4 Or Keys.F5 Or Keys.F6 Or Keys.F7 Or Keys.F8 Or Keys.F9 Or Keys.F10 Or Keys.F11 Or Keys.F12 Or Keys.Enter Then
FuncKeysModule(e.KeyValue)
e.Handled = True
End If
End Sub
If My.Computer.Keyboard.ShiftKeyDown Then
MsgBox("ShiftKey")
End If
(14-09-19, 04:38 AM)Rabeea Qbaha كتب : [ -> ]في الحقيقة جهازي لا يقبل مفاتيح الـ F جميعها لا ادري اذا كان السبب هو الـ virtual machine ام ماذا
لكن الكود يعمل مع المفاتيح الاخرى.
انا سعيد انك وجدت الحل .... تحياتي