View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave F.[_5_] Dave F.[_5_] is offline
external usenet poster
 
Posts: 4
Default Why is this a number?

Thanks for replying.


I'm running this within AutoCAD & don't have the Office Reference ticked.
I'm confused why it would be a specific Excel problem.
Isn't IsNumeric a general VB command?

Is there a way to prevent it happening?

I'm trying to allow only positive numeric values being typed & displayed in
a textbox:

If IsNumeric(OffsetNo) = False Then ' if there is a value in the
textbox & it's not a number
OffsetNo = Left$(OffsetNo, Len(OffsetNo) - 1) ' remove last typed
TxtBx_Dist.Value = OffsetNo ' & put it back in the box
End If

Cheers

Dave F.


"Tom Ogilvy" wrote in message
...
Because Excel knows how to convert it to a number

? clng("45-")
-45

which is the defninition of isNumeric.

Many accounting applications indicate negatives by using the notation you
show.

--
Regards,
Tom Ogilvy

"Dave F." wrote in message
...
Hi
I'm using VBA 6.3

If I pass 45- to this:

If IsNumeric(OffsetNo) = False Then
...

it returns True.

1) Why?

2) How do I prevent this happening?

Thanks in Advance.