引用 | 編輯
overing
2010-01-04 10:03 |
1樓
▲ ▼ |
在Text1的Change事件裡(或KeyRelease事件)
事件參數應該會提供最後輸入的字元(或鍵位code) 抓到是Tab key 就 Call Command1的Click x1 |
引用 | 編輯
ebolaman
2010-01-19 12:46 |
2樓
▲ ▼ |
哦
剛在 VB6 測試了一下,KeyDown, KeyPress, KeyUp 都抓不到 能抓得到的就是 LostFocus 與 Validate 事件,但是無法確定是不到 按下 tab 所造成的 這裡有教學: http://www.china-askpro.com/msg28/qa70.shtml 大概就是當 LostFocus 事件產生時用 API 抓取上一個按鍵是否 tab 鍵這樣 x0 |
引用 | 編輯
三仙
2010-01-19 21:01 |
3樓
▲ ▼ |
下面是引用 DANIELEEL 於 2010-01-02 22:18 發表的 vb6.0--請教條件成立如何自動執行COMMAND1???: 以樓主的要求,其實overing 大的建議就能處理了 在Form_Load()多加上Command1.TabStop = False 如下 複製程式 Private Sub Form_Load() Command1.TabStop = False End Sub Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyTab And Len(Text1.Text) = 6 Then Command1.Value = True End If End Sub Private Sub Command1_Click() MsgBox "因為 Tab 會將 focus 移到物件上" & _ vbCrLf & "而無法觸發事件;在適當時候加入" & _ vbCrLf & "物件.TabStop = False 即可解決!" End Sub 如果Form 上有多個物件則不太適合 因為 Tab 會將 focus 移到物件上 而無法觸發事件 x0 |
引用 | 編輯
三仙
2010-01-19 21:18 |
4樓
▲ ▼ |
複製程式
Private Sub Form_Load() Text1.TabIndex = 0 Command1.TabIndex = 1 End Sub Private Sub Text1_Change() If Len(Text1.Text) = 6 Then Command1.Value = True End If End Sub Private Sub Command1_GotFocus() If Len(Text1.Text) <> 6 Then Exit Sub Command1.Value = True End Sub Private Sub Command1_Click() MsgBox "Form 上有多個物件的另一種解法,供大家參考" End Sub x0 |