newman     VBWeb     VBSource     Portfolio    

AutoTab

TOP TEN

ErrMsg
Used to automatically tab to the next filed when a text box gets filled.
Syntax
AutoTab
Call AutoTab


Remarks
This instruction is specifically designed for the Change event of text boxes with a MaxLength property set greater than zero.

Example
	Sub Text1_Change ()
	    Call AutoTab
	End Sub
	

Source
Sub AutoTab()
    Dim Text1 As Control
    Dim Text As String
    Dim Length As Integer
    Dim MaxLen As Integer

    On Error GoTo AutoTabTrap
    Set Text1 = Screen.ActiveControl
    Text = Text1.Text
    Length = Len(Text)
    MaxLen = Text1.MaxLength
    If Length > MaxLen Then
        'User pasted text longer than the max.
        'This causes another change event so we'll be back.
        Text1.Text = Left$(Text, MaxLen)
    ElseIf Length = MaxLen And Text1.SelStart = MaxLen Then
        SendKeys "{TAB}"
    End If
AutoTabTrap:
    Exit Sub
End Sub
	


Feedback Comments
Return Address (if you want a reply)


Copyright 1997 NEWMAN Services Corp. All rights reserved.
973-228-5753 pres@newmanservices.com
DECONSTRUCT THIS PAGE