Christoph Christoph - 8 months ago 36 Question

how to only allow digits and dots in textbox

i'm wondering how i can get my textbox to only accept digits and dots. like:

or 115
or 218.16978


i allready got the following code:

Private Sub TxtHStof_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtHStof.KeyPress
e.Handled = Not Char.IsDigit(e.KeyChar)

End Sub

But that only allows digits without the dots.
How can i change the code so it does allows the dots aswell, but nothing else. (copy paste doesn't matter since it won't be an issue)

Thanks a lot

e.Handled = Not (Char.IsDigit(e.KeyChar) OR e.KeyChar=".")