Textbox Numeric Input


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ' Number with comma
  2. Private Sub NumberTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles NumberTextBox.KeyPress
  3. Dim tb As TextBox = sender
  4.  
  5. If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar) Or (e.KeyChar = "," And tb.Text.IndexOf(",") < 0)) Then
  6.  
  7. e.Handled = True
  8.  
  9. End If
  10.  
  11. End Sub
  12.  
  13. ' Just Number
  14. Private Sub NumberTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles NumberTextBox.KeyPress
  15. Dim tb As TextBox = sender
  16.  
  17. If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
  18.  
  19. e.Handled = True
  20.  
  21. End If
  22.  
  23. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.