如果是这样的话,我认为是用keypress为好 if keyascii=tab键的ascii码 then text1.setfocus text1.text=" " endif
是這樣的,當我在text1 get focus時按下tab鍵,根本就不發生press等事件
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 9 Then Dim ctrl As Control Set ctrl = Me.ActiveControl ctrl.Enabled = False ctrl.Enabled = True End If End SubPrivate Sub Form_Load() On Error Resume Next Dim ctrl As Control For Each ctrl In Me.Controls ctrl.TabStop = False Next End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 9 Then MsgBox "you pressed TAB" 'KeyCode = 0 End If End Sub
if keyascii=tab键的ascii码 then
text1.setfocus
text1.text=" "
endif
If KeyCode = 9 Then
Dim ctrl As Control
Set ctrl = Me.ActiveControl
ctrl.Enabled = False
ctrl.Enabled = True
End If
End SubPrivate Sub Form_Load()
On Error Resume Next
Dim ctrl As Control
For Each ctrl In Me.Controls
ctrl.TabStop = False
Next
End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then
MsgBox "you pressed TAB"
'KeyCode = 0
End If
End Sub
你知道有什么Api可以解決的嗎
Private Sub Text1_LostFocus()
If GetKeyState(vbKeyTab) < 0 Then
Text1.SetFocus
Msgbox "按了tab键"
End If
End Sub
'from china-askpro.com
Private Sub Text1_Validate(Cancel As Boolean)
If GetKeyState(vbKeyTab) < 0 Then
Cancel = True
MsgBox "按了tab?"
End If
End Sub