Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ascii code not working

Status
Not open for further replies.

Blobishthing

Programmer
Feb 16, 2002
23
AU
I cant work out what is wrong with this code. when i press the buttons nothing happens.

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Unload Me
Else: If KeyAscii = 119 Then frmAbout.Show
Else: Keys.Show
End If
End Sub

Thanx in advance
 
try setting the form's .KeyPreview property to True
may also have to check the structure your If...End If
 
I always find Select Case simpler than IfThenElse's:

Private Sub Form_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
Case 13
Unload Me
Case 119
frmAbout.Show
Case Else
Keys.Show
End Select

End Sub

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top