怎么真正实现用键盘来代替鼠标操作
如何真正实现用键盘来代替鼠标操作?
我测试在每个文本框下做如下的动作,的确能实现用键盘来代替鼠标操作,
现在问题是一个窗体有N多个文本框,这样写起来太费劲,请问各位有没有省事的妙法,谢谢
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Trim(txtName.Text) <> " " And KeyAscii = 13 Then
txtPass.SetFocus
End If
End Sub
Private Sub txtPass_KeyPress(KeyAscii As Integer)
If Trim(txtPass.Text) <> " " And KeyAscii = 13 Then
txtRPass.SetFocus
End If
End Sub
------解决方案--------------------
Option Explicit
Dim w As Integer
Dim i As Integer
Private Sub Form_Load()
w = Text1.Count
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Trim(Text1(0 + i).Text) <> " " And KeyAscii = 13 Then
If i > = w - 1 Then
Command1.SetFocus
Else
Text1(1 + i).SetFocus
End If
End If
i = i + 1
End Sub
我测试在每个文本框下做如下的动作,的确能实现用键盘来代替鼠标操作,
现在问题是一个窗体有N多个文本框,这样写起来太费劲,请问各位有没有省事的妙法,谢谢
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Trim(txtName.Text) <> " " And KeyAscii = 13 Then
txtPass.SetFocus
End If
End Sub
Private Sub txtPass_KeyPress(KeyAscii As Integer)
If Trim(txtPass.Text) <> " " And KeyAscii = 13 Then
txtRPass.SetFocus
End If
End Sub
------解决方案--------------------
Option Explicit
Dim w As Integer
Dim i As Integer
Private Sub Form_Load()
w = Text1.Count
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Trim(Text1(0 + i).Text) <> " " And KeyAscii = 13 Then
If i > = w - 1 Then
Command1.SetFocus
Else
Text1(1 + i).SetFocus
End If
End If
i = i + 1
End Sub