Private Sub OnKeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
e.Handled = (Not Char.IsControl(e.KeyChar)) AndAlso _
(Not Char.IsNumber(e.KeyChar)) AndAlso _
(Not (Char.IsPunctuation(e.KeyChar) And _
(((e.KeyChar = ".") And
(Text.IndexOf(".") = -1)) Or _
((e.KeyChar = "-") And (SelectionStart = 0)))))
End Sub
also take not that if it is something you may use more often, you can create a class that inherits TextBox and change Private to Protected Overrides for the event. Now you have a reusable numeric only textbox class that retains all the orginal textbox functionality