引用 | 编辑
overing
2010-01-04 10:03 |
1楼
▲ ▼ |
在Text1的Change事件里(或KeyRelease事件)
事件参数应该会提供最后输入的字元(或键位code) 抓到是Tab key 就 Call Command1的Click ![]() |
引用 | 编辑
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 键这样 ![]() |
引用 | 编辑
三仙
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 移到物件上 而无法触发事件 ![]() |
引用 | 编辑
三仙
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 ![]() |