TextHeight

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

Syntax

object.TextHeight(string)

Parameters

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

Return Value

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

Remarks

Use TextHeight to determine the amount of vertical space required to display the text. The height returned includes the normal leading space above and below the text, so you can use the height to calculate and position multiple lines of text within object.

If string contains embedded carriage returns, TextHeight returns the cumulative height of the lines, including the leading space above and below each line.