text box

  • Thread starter Thread starter Hechmi
  • Start date Start date
H

Hechmi

Hello,
I have a text box in which I want that a user can only write a number or the
character 'x' but I can't do that
could any one help me please thank you
 
Hello,

Hechmi said:
I have a text box in which I want that a user can only write a
number or the character 'x' but I can't do that
could any one help me please thank you

The best solution is to allow any input and check it in the textbox's
Validating event.

Regards,
Herfried K. Wagner
 
Hello,

Hechmi said:
But are there any way to prevent him to write some characters.

This will prevent the user from typing an "A":

\\\
Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs _
) Handles TextBox1.KeyPress
If e.KeyChar = "A" Then
e.Handled = True
End If
End Sub
///

Regards,
Herfried K. Wagner
 
Back
Top