PDA

View Full Version : Solved: Identify String or Numeric Value in a Textbox



Rlb53
03-14-2012, 07:40 PM
Hello All.

As Always... I have a Textbox in a Userform.
I need to confirm that a Numeric Value is placed into this Textbox before the Code Continues. If an alpha value is inserted into the textbox it throws an error code because it is directly attached to a Numeric Formula.

If possible... I'd like to use a simple "If, Then" statement.

Can you help me correct the syntax please?

If IsText(Qty.Value) Then
MsgBox " You must enter a Valid Quantity"
Qty.SetFocus
Qty.Value = ""
Exit Sub
End If

Thank you Once Again !

frank_m
03-14-2012, 07:52 PM
Try this:

Private Sub qty_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsNumeric(Me.qty.Value) Then
MsgBox " You must enter a Valid Quantity"
Me.qty.SetFocus
Me.qty.Value = ""
End If
End Sub

Rlb53
03-14-2012, 07:59 PM
Awesome !... Just Pure Awesomeness on this Forum !

Thank You !