kwangu

Disable string characters in textbox

Nov 23rd, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.34 KB | None | 0 0
  1. Private Sub Textbox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Textbox1.KeyPress
  2.         If e.KeyChar = "."c Then
  3.             e.Handled = (CType(sender, TextBox).Text.IndexOf("."c) <> -1)
  4.         ElseIf e.KeyChar <> ControlChars.Back Then
  5.             e.Handled = ("0123456789".IndexOf(e.KeyChar) = -1)
  6.         End If
  7.     End Sub
Add Comment
Please, Sign In to add comment