Private Sub objTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles objTextBox.KeyDown
If e.KeyCode = 13 Then
MsgBox(objTextBox.Text)
else
MsgBox(e.KeyCode)
End If
End Sub
运行后,除按回车键没反应外,其它都会跳出对话框,不知何原因?按理按回车键执行 MsgBox(objTextBox.Text)这句才对啊!困惑啊!!!
4 个解决方案
#1
e.KeyCode == Keys.Enter
#2
e.KeyCode = Keys.Enter
#3
你是不是为窗体设置了AcceptButton?
#4
谢谢各位,特别是3楼的!!!
#1
e.KeyCode == Keys.Enter
#2
e.KeyCode = Keys.Enter
#3
你是不是为窗体设置了AcceptButton?
#4
谢谢各位,特别是3楼的!!!