RP1America
Technical User
I am having a hard time finding what I need.
I have the code below that only allows entry of numerics and one decimal and shows in 0.00 format.
I would like the user to be able to enter a decimal as the first character when inputting data. (e.g. ".25")
Currently with this code, a zero would need to be entered first (e.g. "0.25")
Any thoughts on how to take my current code and allow a decimal to be the first thing entered by the user?
I have the code below that only allows entry of numerics and one decimal and shows in 0.00 format.
I would like the user to be able to enter a decimal as the first character when inputting data. (e.g. ".25")
Currently with this code, a zero would need to be entered first (e.g. "0.25")
Any thoughts on how to take my current code and allow a decimal to be the first thing entered by the user?
Code:
Private Sub txtTime_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtTime.Text = Format(Round(CDec(txtTime.Text) / 0.25) * 0.25, "0.00")
End Sub
Code:
Private Sub txtTime_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, Me.txtTime.Text, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub