版友大海同志的问题:如何在输入框中输入限定字符数后光标能自动跳到下一个输入框?
解 答:
Private Sub Form_Load()
Dim ctl As Control
Me.姓名.Tag = "3"
Me.性别.Tag = "1"
Me.年龄.Tag = "2"
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.OnChange = "=AllChange()"
End If
Next ctl
End Sub
Function AllChange()
Dim ctl As Control
Me.Recalc
Me.ActiveControl.SelStart = Len(Nz(Me.ActiveControl.Value, "0"))
If Len(Me.ActiveControl.Value) = CLng(Me.ActiveControl.Tag) Then
SendKeys "{ENTER}"
End If
End Function
附 件:
点击下载此附件
演 示: