Disable Special Characters

GavZ

Mostly Beginners Luck!
Local time
Today, 07:39
Joined
May 4, 2007
Messages
56
Hi - Can anyone tell me how to disable Special Characters in a Textbox

Thanks in advance!
 
you can capture them in the OnKeyPress event of the text box.
 
I've found using OnKeyPress and OnKeyDown becomes problematical when dealing with <Shift> + <Another key> combinations and for something like this I'd use something like

Code:
Private Sub ControlName_Change()
  If Right(Me.ControlName.Text, 1) Like "[#,!,@,$,%,&]" Then Me.ControlName.Text = Left(Me.ControlName.Text, Len(Me.ControlName.Text) - 1)
End Sub
where ControlName is replaced with the actual name of your textbox. Simply add any additional characters to block to

[#,!,@,$,%,&]

separating them by a comma.
 

Users who are viewing this thread

Back
Top Bottom