Re: converting points to centimeters...



Hi Jean-Guy

Thanks for that explanation. I suppose that Word's rounding to the nearest
hundredth of a point is necessary (it can't go to an infinite number of
decimal points), and Word's unfortunate points orientation is an evil we all
have to live with.

I'm not comfortable with the rounding because it's not controllable - it's
quite possible that a user may want a specific measurement that will be
unachievable because of the points-rounding and the results-rounding. But
that's life. You can't always get what you want.

I'm going to have to do the rounding manually in the code because the
solution has to be Word 97 compatible and I don't believe there's a Round
function or method available in 97.

Thanks again.

"Jean-Guy Marcil" wrote:

> Sam was telling us:
> Sam nous racontait que :
>
> > Hi Doug
> >
> > Thanks again for the suggestion. Unfortunately the Single variable
> > doesn't seem to help. I modified my code as below. The msgbox x
> > still returns
> > 1.250597. The problem seems to arise when the CentimetersToPoints
> > value is stored or when the setting is converted back - your code
> > works fine but it doesn't actually convert and store the value or
> > convert a stored value.
> >
> > Any ideas as to what's going on and how to fix it?
>
> I can tell you what is going wrong, but I am not sure about the fixing
> part..
>
> The problem is not the conversion itself, but the act that Word rounds the
> list value to the nearest 0.05 point.
>
> x = CentimetersToPoints(1.25)
>
> results in x being equal to 35.43307.
>
> But,
> Dim x As Single
> With lstListTemplate.ListLevels(1)
> x = .NumberPosition
> MsgBox x
> End With
>
> yields a value of 35.45, which once converted in cm is exactly 1.250597.
>
> If you try with
> x = 35.43307
> when setting up the list template you still end up with 35.45.
>
> No matter what I tried, I either ended up with 35.4 or 35.45.
>
> When you work with inches, it so happens that 1.25 inches is exactly 90
> points (1 inch = 72 points), so no rounding up occurs.
>
> If you do the whole thing by hand, you will only see 1.25 cm because Word
> does not allow/ignores the 3rd digit after the decimal point, so you would
> never see it as 1.250597.
>
> I do not think it can be fixed.
>
> I guess that it you round up the x in
> x = PointsToCentimeters(.NumberPosition)
> MsgBox x
> to 2 digits after the decimal point, the result will be OK anyway... so
> there isn't really a problem.
>
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@xxxxxxxxxxxxxxxxxxxxxxx
> Word MVP site: http://www.word.mvps.org
>
>
>
>
.



Relevant Pages

  • Re: Fastcode RoundTo
    ... The rounding control could be like the following: ... {Round to nearest else to even digit. ... drHalfOdd, {Round to nearest else to odd digit. ...
    (borland.public.delphi.language.basm)
  • Re: Rounding error when doing float-to-integer
    ... there is no "round to seven ... I said that the rounding error was due to first rounding to seven ... > conversion of the 0.002 to binary, which you seem to be ignoring. ... No I am not ignoring it, the rounding error alone does not seem to ...
    (comp.lang.fortran)
  • Re: Presidential Golden Dollar Coins
    ... No problem here knowing how to round. ... I think rounding to the nearest nickel would work. ...
    (rec.collecting.coins)
  • Re: What categories do these expenses fall into ?
    ... this makes the numbers add up but 120.37 rounded to the nearest ... The reasoning is that the imprecision added by rounding sometimes ... to round one or more of the figures the "wrong" way. ... Or you could do it on the basis of smaller relative error. ...
    (uk.business.accountancy)
  • Re: Forcing numbers to round up or down
    ... Do note, though, that the rounding will be reversed ... down will round up, and the one that rounded up will round down. ... "Kim Crenshaw" wrote in message ... >>> a new number which is rounded DOWN to nearest whole number if it is ...
    (microsoft.public.access.forms)