
Originally Posted by
Nicomendox
I am not rounding any margin value.
Oh yes you are.

Originally Posted by
Nicomendox
Used Math.Truncate(number) to disable Round.
But you used it wrong, so it is actually rounding toward zero. Example:
vb.net Code:
hght = Math.Truncate(((33.9) * 100) / 100)
If we exapnd that out it becomes this:
vb.net Code:
Dim a = 33.9
Dim b = (a) * 100 'a = 339.0
Dim c = (b) / 100 'b = 33.9
hght = Math.Truncate(c) 'hght = 33.0
What you actually should be doing is this:
vb.net Code:
Dim a = 33.9
Dim b = (a) * 100 'a = 339.0
Dim c = Math.Truncate(b) 'c = 339.0
hght = (c) / 100 'hght = 33.9
If you hadn't included so many useless parentheses then you wouldn't have missed the wood for the trees:
vb.net Code:
hght = Math.Truncate(33.9 * 100) / 100
You should have been able to work this out for yourself because you should have done exactly what I did , i.e. expanded the single lines that performed multiple operations into multiple lines that performed a single operation each. Had you done that and actually debugged the code, the issue would have been obvious.
Of course, if you're using literal values then why is any of that being used at all? 33.9 is 33.9, whether it's a literal or the result of a calculation. What do you think that that code is accomplishing?
Just use a Decimal literal in the first place. You also must have Option Strict Off or else assigning a Double to a Decimal variable, as you are doing, would not be allowed. Turn Option Strict On in the project and the IDE and use Decimal literals where you need Decimal values.