>WITH YourTextbox > lcFontStyle = IIF(.FONTBOLD,"B","") + ; > IIF(.FONTITALIC,"I","") + ; > IIF(.FONTSTRIKETHRU,"-","") + ; > IIF(.FONTUNDERLINE,"U","") > > lnFontMetric = FONTMETRIC(6,.FONTNAME ,.FONTSIZE,lcFontStyle) > >.WIDTH = CEILING(TXTWIDTH(.VALUE, ; > .FONTNAME,.FONTSIZE,lcFontStyle)+1)*lnFontMetric > >ENDWITH &&YourTextbox >>
for 'i' it returns 3 for 'WWWWWWWWWW' it returns 110 for 'WWWWWWWWWWi' it returns 113 call: local obj, nWidth, nHeight obj = m.thisform.Text1 if( Text_Properties_Get(m.obj, rtrim(m.obj.Text), @m.nWidth, @m.nHeight) ) ?m.nWidth, m.nHeight endif *--- function Text_Properties_Get(obj, txt, Width, Height) local Success Success = TRUE local FontBold, FontItalic, FontName, FontSize, FontStrikeThru, FontUnderLine with _screen FontBold = .FontBold FontItalic = .FontItalic FontName = .FontName FontSize = .FontSize FontStrikeThru = .FontStrikeThru FontUnderLine = .FontUnderLine .FontBold = m.obj.FontBold .FontItalic = m.obj.FontItalic .FontName = m.obj.FontName .FontSize = m.obj.FontSize .FontStrikeThru = m.obj.FontStrikeThru .FontUnderLine = m.obj.FontUnderLine Height = .TextHeight(m.txt) Width = .TextWidth(m.txt) .FontBold = FontBold .FontItalic = FontItalic .FontName = FontName .FontSize = FontSize .FontStrikeThru = FontStrikeThru .FontUnderLine = FontUnderLine endwith return m.Success endfunc *-------------------------------------------------------------------------------