Code change for chars

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

i have the following code to only allow integer values to be entered in a textbox
Can anyone tell me how i can modify this to only allow characters?

Private Sub txtBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBox1.KeyPres
'ensure that only integers can be entere
If Char.IsNumber(e.KeyChar) The
Exit Su
End I
If Not Char.IsNumber(e.KeyChar) The
e.Handled = Tru
End I
End Su
 
Depends what you mean with characters. If you mean characters as letters,
then you have a method in Char.IsLetter

Fitim Skenderi


Why/ said:
Hi,

i have the following code to only allow integer values to be entered in a textbox.
Can anyone tell me how i can modify this to only allow characters??

Private Sub txtBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtBox1.KeyPress
 
Back
Top