View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default checking for a numeric value in a textbox

If IsNumeric(TextBox1.Value) = True Then
' do nothing
Else
TextBox1.Value = ""
End If

Something like that..If the textbox is on a UserForm you may have to qualify
it more
Me.TextBox1 or UserForm1.TextBox1 etc.
Mike F
"mark" wrote in message
...
Hi.

I have a couple of textboxes on a vb form. For these, I need the value
entered to be sure to be numeric.

What's the best way to check for that?

application.isnumber(txtBox.value) returns false... becauese it thinks its
text.

the Val(txtBox.value) function does some checking, but it will tell you
that
Val(5a) = 5, etc.

I think one time I did some checking on the len of Val(), as compared to
the
original len of the entry, but that probably has holes too.

Please point me toward the simple way.

Thanks.