arithmetic mistakes

C

Clive Tolley

I have just debugged various errors in a program for Word as due to VBA's
apparent inability to perform simple arithmetic. A simple piece of code such
as:
Dim s As Single
s = 0.05
For i = 1 To 240
s = s + 0.1
MsgBox s
Next i
produces errors on about a third the numbers generated (and the number type
seems to make no difference - same with Double, anyway).
What is going on?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top