dwb dwb - 11 months ago 63
Vb.net Question

Disable input for a single character in a textbox

I have an application that works with a 3rd party ticketing software to submit/update tickets. The issue I am having is, the ticketing software reads the character : as a new input. What I am trying to do is disable ONLY : from being entered into a textbox.

I have done some research and found ways to, Disable letters/numbers/special, but not one for only a single one.

Any help would be greatly appreciated.

Answer Source

Try this:

 Private Sub txtchange() Handles TextBox1.TextChanged
    TextBox1.Text = TextBox1.Text.Replace(":", "")
    TextBox1.SelectionStart = TextBox1.Text.Length
End Sub

Replace TextBox1 with your textbox name