>It did not work properly. I got the answer as 66 with following command
>
>?FONTMETRIC(7,"MS Sans Serif",9)*LEN("WWWWWW")
>
>After changing the width to 66 also, last 'W' did not get displayed fully.
As Hilmar and Caroline already pointed out, you also must take the border and margin in consideration. Also, an extra 2 pixel constant seems appropriate (create a label with
.caption="WWWWWW" and
.autosize=.t. and you get a 68
.width) so unless someone else comes with a better formula it should be
Text.Width = FONTMETRIC(7,oText.FontName,oText.FontSize)*oText.MaxLength+oText.Margin*2+oText.BorderStyle*4+2
----------------------------------
António Tavares Lopes