![]() |
Click here to advertise with us
|
|
|||||||
| Windows Forms Discussion related to Winforms application development |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
For example, if you want to textbox2 allow import of only the digits from 1 to 5 try this:
Code:
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar < Chr(49) Or e.KeyChar > Chr(53) Then e.Handled = True
End Sub
maybe you will need this: Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion I hope that I helped
|
|
||||
|
Another way is this:
Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Select Case e.KeyCode
Case Keys.A, Keys.B, Keys.C
'allowed
Case Else
'not allowed
e.SuppressKeyPress = True
End Select
End Sub
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|