Returns the width of a text string as it would be printed in the current font of a Form, PictureBox, or Printer. Named arguments are not supported.
object.TextWidth(string)
The parts of the TextWidth method syntax are described in the following table.
Part | Description |
---|---|
object | Optional. An object expression that evaluates to an object. 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.