Ich werd von vb verarscht!

Option Explicit
Private Sub Form_KeyPress(Key As Integer)
If Key = vbKeyUp Then
MsgBox "hi"
End If
End Sub

Es kommt keine Message!!!

nachtrag: vb 6.0. Was soll ich nur tun?

Option Explicit
Private Sub Form_KeyPress(Keycode As Integer)
MsgBox "test"

If Keycode = vbKeyUp Then
MsgBox "hi"
End If
End Sub

auch das nicht!?
 
Hi,

Wenn ich mich nicht täusche, funktionien die KeyPress Events nur, wenn die Form den Fokus hat.
Funktioniert es denn mit anderen Taste, z.B. mit Buchstaben?

Ist lange, als ich das letzte mal mit VB6 arbeitete... C# ist da um einiges besser :)

Gruß Chris
 
Das KeyPress-Event wird nur ausgelöst wenn eine Taste gedrückt wird die einem darstellbaren Zeichen entspricht (Buchstaben, Zahlen, etc. aber _nicht_ F1-F12, Pfeiltasten, etc.). Das was du brauchst ist das KeyDown-Event!

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = vbKeyUp Then
  msg = MsgBox("Test")
 End If
End Sub
Hier noch ein paar Tipps:
 
Zurück
Oben