difference with the same value get error

User avatar
sal21
PlatinumLounger
Posts: 4354
Joined: 26 Apr 2010, 17:36

difference with the same value get error

Post by sal21 »

See image attached if is possible!!!!!!


Note:
all var are dimensioned double
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: difference with the same value get error

Post by HansV »

It could be due to a rounding error. Try adding a line

Debug.Print IMPORTO_OPERAZ - SECONDO_TOT
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4354
Joined: 26 Apr 2010, 17:36

Re: difference with the same value get error

Post by sal21 »

HansV wrote:It could be due to a rounding error. Try adding a line

Debug.Print IMPORTO_OPERAZ - SECONDO_TOT
wow!!!!!!!!!!!!!

this is the result of Debug.Print IMPORTO_OPERAZ - SECONDO_TOT
4,54747350886464E-13

How to adjust?

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: difference with the same value get error

Post by HansV »

If the numbers are amounts of money, you could round the numbers to 2 decimal places:

SECONDO_TOT = Round(PRIMO_TOT - RESTO, 2)

Or you could declare the variables as Currency instead of as Double.
Best wishes,
Hans