I'm attempting to write a function that checks users input and verifies it's numeric. When it isn't I would like to keep the part of the string that's numeric and remove the last character after a messagebox pops up alerting the user to the violation. Here is the code I have thus far:
If TypeName(Me.ActiveControl) = "TextBox" Then
With Me.ActiveControl
If Not IsNumeric(.Text) And .Text <> vbNullString Then
MessageBox.Show("Sorry, only numbers allowed")
.Text = .Text vbNullString
End If
End With
End If
But this erases the entire textbox string and I have to start over.
Any help would be greatly appreciated.