vb的一条简单问题

来源:百度知道 编辑:UC知道 时间:2024/06/14 19:51:23
画两个按钮,一个为"yes",一个为"no",无论在任何情况下按回车键就等于按"yes",按ESC键就是按"no".请问这该如何实现

Private Sub Form_Load()
Me.KeyPreview = True
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then '如果按的键是Esc
'过程
End If
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then KeyAscii = 0 ‘下面写过程
'就是这里写
end if
End Sub