PDA

Click to See Complete Forum and Search --> : Remove Ctrl+Tab from user input in VBA


cssriraman
Feb 9th, 2006, 04:37 AM
Hi,

I have a text box in vba userform. In run time, if the user presses Ctrl + Tab it appears in text box. Normally in vb it will not accept Ctrl+Tab. but, in vba it accepts Ctrl+Tab in text box. how to avoid this in vba. i.e., If the user presses the Ctrl+Tab nothing should happen.

Thanks in advance

Hack
Feb 9th, 2006, 05:56 AM
VBA question moved to Office Development

RobDog888
Feb 9th, 2006, 11:25 AM
You can trap for the Tab (chr(9)) in the change event of the textbox and parse it out.
Private Sub TextBox1_Change()
If InStr(1, TextBox1.Text, Chr(9)) > 0 Then
TextBox1.Text = Replace(TextBox1.Text, Chr(9), "")
End If
End Sub

RobDog888
Feb 9th, 2006, 11:29 AM
Also make sure the TabKeyBehavior property is set to False. ;)