Visual Basic Reference

Visual Studio 6.0

TextWidth Method

See Also    Example    Applies To

Returns the width of a text string as it would be printed in the current font of a Form, PictureBox, or Printer. Doesn't support named arguments.



The TextWidth method syntax has these parts:

Part Description
object Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
String Required. A string expression that evaluates to a string for which the text width is determined. Parentheses must surround the string expression.


The width is expressed in terms of the ScaleMode property setting or Scale method coordinate system in effect for object. Use TextWidth to determine the amount of horizontal space required to display the text. If string contains embedded carriage returns, TextWidth returns the width of the longest line.