ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do Until problem (https://www.excelbanter.com/excel-programming/331944-do-until-problem.html)

David Goodall[_2_]

Do Until problem
 
Morning
I've set up a do until loop but it doesn't stop when the two conditions
appear to be the same.

The two variable I'm comparing are declared as Double and I think that's
where the problem lies. When I debug the watches are as follows:-

Variable1 = 39779.4028
Variable2 = 39779.4028

They appear to be the same but I'm thinking that not all the decimals are
being shown. I only need the answers to 2 decimal points ie 39779.40 so
would you suggest casting the double to another variable type.

Hope this makes sense.
Thanks
David




Bob Phillips[_7_]

Do Until problem
 
David,

How about

Do
...
Loop Until Round(var1,2) = Round(var2,2)


--
HTH

Bob Phillips

"David Goodall" wrote in message
...
Morning
I've set up a do until loop but it doesn't stop when the two conditions
appear to be the same.

The two variable I'm comparing are declared as Double and I think that's
where the problem lies. When I debug the watches are as follows:-

Variable1 = 39779.4028
Variable2 = 39779.4028

They appear to be the same but I'm thinking that not all the decimals are
being shown. I only need the answers to 2 decimal points ie 39779.40 so
would you suggest casting the double to another variable type.

Hope this makes sense.
Thanks
David







All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com