View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Numerical accuracy in Form Text-boxes

On Sat, 23 Aug 2003 11:04:33 +1000, IM wrote:

Ron

Thanks for the reply. I do know exactly how numbers are stored and the
cause of round-off errors. But what irks me is the problem of
consistency. What I mean by that is if I enter 14.6 in a worksheet cell,
the problem I mentioned will never happen. But if the number is
extracted from a textbox via VBA, it does.

Apparently, Excel by itself works fine in this respect. Only its
interfacing with VBA that will bring up the problem. I just wonder if
that's an inherent problem with Visual Basic. If yes, Microsoft could
handle that easily, since there is no problem with that within Excel.

IM


Could there be an issue in your code?

If I enter 14.6 into an input box, assign it to a variable which has been dim'd
as double, and then print it, I get 14.6

Very simply:

=============
Sub test()
Dim c As Double
c = InputBox("Enter a number")
Debug.Print c
End Sub
============

It seems as if VBA is handling 14.6 OK in this simple routine.


--ron