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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top