button1.KeyPress
Try
Dim KeyAscii As Short= Asc(e.KeyChar)
Dim iAfterDecimal AsInt16 = 0
If CType(sender, TextBox).SelectionStart > txtFillTank.Text.IndexOf(".") AndAlso Not txtFillTank.Text.IndexOf(".") = -1Then
iAfterDecimal = txtFillTank.Text.Length - (txtFillTank.Text.IndexOf(
"."))
EndIf
If (KeyAscii >= Keys.D0 And KeyAscii <= Keys.D9 And iAfterDecimal <= 4) Or KeyAscii = System.Windows.Forms.Keys.BackThen
e.Handled =
False
ElseIf KeyAscii = Keys.DeleteThen
If txtFillTank.Text <> String.EmptyThen
If txtFillTank.Text.Contains(".")Then
e.Handled =
True
Else
e.Handled =
False
EndIf
EndIf
Else
e.Handled =
True
EndIf
Catch ex AsException
EndTry
EndSub