Private Sub Command1_Click()
MsgBox "OK"
Unload Me
End SubPrivate Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
Unload Me
End If
End SubPrivate Sub Form_Load()
Form1.KeyPreview = True
Command1.Default = True
End Sub
MsgBox "OK"
Unload Me
End SubPrivate Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
Unload Me
End If
End SubPrivate Sub Form_Load()
Form1.KeyPreview = True
Command1.Default = True
End Sub
MsgBox "OK"
Unload Me
End SubPrivate Sub Command2_Click()
MsgBox "Cancel"
Unload Me
End SubPrivate Sub Form_Load()
Command1.Default = True
Command2.Cancel = True
End Sub
写的真够详细!
设置按钮的 default 和 Cancel 属性。
如果这样的话,很简单,你把确定按钮的Default属性设为True,把取消按钮的Cancel属性设为True
case =13:command1_click(0)'回车
case =27:command1_click(1)'ESC
end select不过写的地方可能要多一点。