VB程序如何实现程序按"Esc"键退出?

来源:百度知道 编辑:UC知道 时间:2024/06/07 00:19:45

Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then End
End Sub

其它同楼上:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
End
End If
End Sub

将 FORM 的 KEYPREVIEW 设为 TRUE。

在 KEY_PRESS 里处理就可以了

两位回答都对啊.