> Hi Stefan,

>

> Interesting.

>

> Strange though - I set up a form with 'Courier New' 12 and .TextWidth(SPACE(x)) gives 10x as the answer.

>

> When I try that the box is always not wide enough by 10.

>

> So the answer should really have been 10x + 10 and not 10.

>

> eg. Let the TextBox = 'VERY WEIRD' and try this with .Width = 100.

>

> It doesn't quite fit but 110 looks good.

>

> Do you get the same at your end?

>

> Anyway, I never knew of .TextWidth.

>

> Thanks.

You're welcome, Russell. I get the same difference here, which I think is related to Textbox.Margin and its border width.

IOW, when you add its .Margin*2 and set BorderStyle = 0, the width should match:

LOCAL loForm as Form
loForm = CreateObject('Form')
loForm.FontName = "Courier New"
LOCAL lcString
lcString = "Test String"
loForm.AddObject('Text1','Textbox')
loForm.Text1.Move(50,50)
loForm.Text1.FontName = m.loForm.FontName
loForm.Text1.BorderStyle = 0
loForm.Text1.Visible = .T.
loForm.Text1.Value = m.lcString
loForm.Text1.Width = m.loForm.TextWidth(m.lcString) + loForm.Text1.Margin * 2
loForm.Show()
WAIT WINDOW
loForm.Text1.Width = m.loForm.TextWidth(m.lcString)
loForm.Text1.Margin = 0
WAIT WINDOW

hth

-Stefan