TextWidth

This method returns the width of a text string as it would be printed in the current font of a Form or PictureBox control.

Syntax

object.TextWidth(string)

Parameters

object
Optional. Object expression that evaluates to a form or PictureBox control. If object is omitted, the Form with the focus is assumed to be object.
string
Required. String for which the text width is determined.

Return Value

Length of string in terms of the ScaleMode property setting of object.

Remarks

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.