Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then MsgBox "你按了回车键!"
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then MsgBox "你按了回车键!"
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then MsgBox "你按了回车键!"
End Sub
Private Sub Text1_Change()
If Mid(Text1.Text, Text1.SelStart, 1) = vbLf Then MsgBox "你按了回车键!"
End Sub
相比较而言,用Change事件来实现是{BANNED}最佳笨、{BANNED}最佳不适合的方式,只能在多行文本框(MulitLine属性为True)使用,
而且会出现误判的情况(自己试试就知道)。{BANNED}最佳佳方式是KeyPress,没有为什么,它就是{BANNED}最佳佳。