VB KeyEnter问题请教

来源:百度知道 编辑:UC知道 时间:2024/07/05 14:49:30
比如在文本框里按下回车相当于用鼠标点了command1一下!我在text1下写了KeyDowon事件,然后是If Keydown(keyenter!) then下面不知道怎么写激活command1的click事件的代码了

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Call command1_click
End Sub

call command1_click

Private Sub Command1_Click()
MsgBox "你按了回车,或者点了按钮Command1"
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Command1.Value = True
End Sub

keyenter 改为 vbKeyReturn 或 13

引用上面的一段代码:
Private Sub Command1_Click()
MsgBox "你按了回车,或者点了按钮Command1"
End Sub

然后是
If Keydown(keyenter!) then
call Command1_Click()
end if