Remove Ctrl+Tab from user input in VBA
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
Re: Remove Ctrl+Tab from user input in VBA
VBA question moved to Office Development
Re: Remove Ctrl+Tab from user input in VBA
You can trap for the Tab (chr(9)) in the change event of the textbox and parse it out.
VB Code:
Private Sub TextBox1_Change()
If InStr(1, TextBox1.Text, Chr(9)) > 0 Then
TextBox1.Text = Replace(TextBox1.Text, Chr(9), "")
End If
End Sub
Re: Remove Ctrl+Tab from user input in VBA
Also make sure the TabKeyBehavior property is set to False. ;)