|
-
Apr 24th, 2009, 04:06 AM
#1
Thread Starter
Fanatic Member
-
Apr 24th, 2009, 04:21 AM
#2
Re: Round to nearest specified value
\ is an operator for Long or Integer data type.
x = 1000 \ 0.1 = CInt(1000) \ CInt(0.1) = 1000 \ 0 : Division by zero!
With Variant/Double, change to:
Code:
RoundToNearest = RoundToNearestVal * Int(NumberToRound / RoundToNearestVal)
-
Apr 24th, 2009, 04:30 AM
#3
Thread Starter
Fanatic Member
Re: Round to nearest specified value
Hi anhn. Not sure I understand. NumberToRound \ RoundToNearestVal still returns <Division by zero> and causes an error.
Why is NumberToRound \ RoundToNearestVal set to a Variant/Integer type in the watch window?
-
Apr 24th, 2009, 05:15 AM
#4
Re: Round to nearest specified value
Just as anhn said, these are implicitly converted to integers or long before division, when you use the \ operator.
-
Apr 24th, 2009, 05:18 AM
#5
Thread Starter
Fanatic Member
Re: Round to nearest specified value
Ohh.. I didn't notice the \ / difference.
Thankyou both!
-
Apr 24th, 2009, 05:23 AM
#6
Re: Round to nearest specified value
\ = integer division
/ = decimal division
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|