vba - How to make For loop work with non integers -



vba - How to make For loop work with non integers -

the next code easy , outputs expected

code:

option explicit sub test_loop2() dim long = -3 3 step 1 debug.print next end sub

output:

the next code exiting due rounding

option explicit sub test_loop2() dim double = -0.3 0.3 step 0.1 debug.print next end sub

output:

what reliable method can utilize whilst retaining for loop ensure lastly value run in loop non integers?

eg = x y step z - y must reached if it's multiple of z

for = 0 0.3 step 0.1 0.3 in loop

for = 0 0.3 step 0.2 0.3 not in loop

floating point arithmetic screw if utilize double (or single) counter.

for counters, stick whole numbers. derive floating point value counter. example:

dim long dim d double = 0 6 d = (i - 3) * 0.1 ' or whatever formula needed debug.print d next

vba

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -