My userform opens, I key in a 5 in Textbox 4 (which meets the test of a number per my function), and it is formatted as $5 in the exit event. All is well.
Tabbing through the form, the next time around, without any changes to Textbox4, the AfterUpdate event gets triggered and I get the message "not a number". Why is the after update triggering -- nothing was changed?
Tabbing through the form, the next time around, without any changes to Textbox4, the AfterUpdate event gets triggered and I get the message "not a number". Why is the after update triggering -- nothing was changed?
Code:
Private Sub TextBox4_AfterUpdate()
If Not IsDigitsOnly(TextBox4) Then
MsgBox ("not a number")
TextBox4 = 0
End If
End Sub
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox4 = Format(TextBox4, "$0")
End Sub
Function IsDigitsOnly(Value As String) As Boolean
IsDigitsOnly = Not Value Like "*[!0-9]*"
End Function