|
-
Sep 27th, 2005, 08:11 PM
#1
Thread Starter
Junior Member
[RESOLVED] No ABC Chars!
Ok, I used this code to stop letters from being entered into a txtBox, could someone help me to change this so that Nums cannot be entered.....
VB Code:
Private Sub txtExponent_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles txtExponent.KeyPress, txtInput.KeyPress
If e.KeyChar Like "[!a-zA-Z]" AndAlso Not e.KeyChar = ControlChars.Back Then
e.Handled = True
End If
End Sub
End Class
-
Sep 27th, 2005, 08:21 PM
#2
Re: No ABC Chars!
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsNumber(e.KeyChar) Or Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
-
Sep 27th, 2005, 08:45 PM
#3
Re: No ABC Chars!
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsLetter(e.KeyChar) Then
'The character being entered is a letter.
ElseIf Char.IsDigit(e.KeyChar) Then
'The character being entered is a decimal digit.
ElseIf Char.IsControl(e.KeyChar) Then
'The character being entered is a control character.
End If
End Sub
The Char type has some other useful methods you should familiarise yourself with also.
-
Sep 28th, 2005, 07:18 PM
#4
Thread Starter
Junior Member
Re: [RESOLVED] No ABC Chars!
Thank you "Again" people!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|