Enter the text box in VB.NET

xiaoxiao2021-03-06  42

Enter the text box in VB.NET

In VB.NET, the input control of the text box can be implemented by simple code. As shown below:

To implement the input to the three text boxes as required, simply add KeyPress events to each text box, the code is as follows:

'TextBox1 only input digital Private Sub TextBox1_KeyPress (ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar> "0" AndAlso e.KeyChar < "9" Then e.Handled = False Else e.Handled = True End If End Sub 'TextBox2 only letters, regardless of case Private Sub TextBox2_KeyPress (ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress Select Case e. Keychar case "a" to "z" e.Handled = false case "a" to "z" E.handled = false case else e.handled = true end Sub 'Textbox3 can only enter uppercase letters private sub textbox3_keypress (ByVal) Sender as object, byval e as system.windows.Forms.keypressEventArgs) Handles TextBox3.KeyPress Select Case E.Keychar Case "a" to "z" e.handled = false case else e.handled = true end SEL Ect End Subif (E.KEYCHAR> = Chr (keys.d0) And e.keychar <= chr (keys.d9)) or e.keychar = chr (keys.insert) or e.keychar = chr (keys.space) OR E.Keychar = chr (keys.back) or E.keychar = chr (keys.delete) Then E.handled = false else e.handled = true endiff

Only numbers are allowed, others are almost the same. You can try

转载请注明原文地址:https://www.9cbs.com/read-61546.html

New Post(0)