是有的,但是應該在keyDown中. 如: Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then '這裡就可以寫你的代碼了。。 End If End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode=13 then msgbox"你按下了回车键" End IF End Sub
Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then '..... End If End Sub
Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then if trim(TxtABC.text)<>empty then Call SavatextToDb(trim(TxtABC.text)) DoEvents '因為數據庫寫動作,將系統權交給別的處理線程。可以不要這句。 end if End If End Subprivate Sub SavatextToDb(byval Lstr_TxtAbc.Text) dim .......
On Error ..... '這裡可以寫代碼了 End sub
Private Sub Text1_KeyPress(KeyAscii As Integer) If (KeyAscii = 13) Then Me.Caption = Text1.Text End If End Sub
如:
Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
'這裡就可以寫你的代碼了。。
End If
End Sub
If KeyCode=13 then
msgbox"你按下了回车键"
End IF
End Sub
If KeyCode = 13 Then
'.....
End If
End Sub
If KeyCode = vbKeyReturn Then
if trim(TxtABC.text)<>empty then
Call SavatextToDb(trim(TxtABC.text))
DoEvents '因為數據庫寫動作,將系統權交給別的處理線程。可以不要這句。
end if
End If
End Subprivate Sub SavatextToDb(byval Lstr_TxtAbc.Text)
dim .......
On Error ..... '這裡可以寫代碼了
End sub
If (KeyAscii = 13) Then
Me.Caption = Text1.Text
End If
End Sub