Hello guys, newbie here asking for help...
I am working on a userform wich requieres the user to fill some information on different textboxes, they can contain only decimal numbers and must have either a plus or minus sign at the beggining, e.g:
+1.25
-0.75
-2.25
I can´t figure out what would be the correct format for the textbox, and how to force the user to input + or - sign before the numbers. So far I have this:
So if I try to input something like:
-0.25
after leaving the textbox I get:
-25,
Crossing fingers for some help, thanks in advance!
I am working on a userform wich requieres the user to fill some information on different textboxes, they can contain only decimal numbers and must have either a plus or minus sign at the beggining, e.g:
+1.25
-0.75
-2.25
I can´t figure out what would be the correct format for the textbox, and how to force the user to input + or - sign before the numbers. So far I have this:
VBA Code:
Private Sub mytb_AfterUpdate()
Me.mytb.value = Format(Me.mytb.value, "+#0.##;-#0.##")
End Sub
Private Sub mytb_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case vbKey0 To vbKey9
Case vbKeySubtract
Case Asc("-")
Case vbKeyAdd
Case Asc("+")
Case vbKeyDecimal
Case vbKeyDelete
Case vbKeyBack
Case vbKeyReturn
Case Else
KeyAscii = 0
Beep
End Select
End Sub
So if I try to input something like:
-0.25
after leaving the textbox I get:
-25,
Crossing fingers for some help, thanks in advance!