Printer.TextHeight Method (String)


Returns the height of a text string as it would be printed in the current font.

Namespace:   Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)


public float TextHeight(
    string text
float TextHeight(
    String^ text
member TextHeight : 
        text:string -> float32
Public Function TextHeight (
    text As String
) As Single


Return Value

Type: System.Single

Returns a Single.


The height is expressed in units of measurement specified by the ScaleMode property setting or the Scale method coordinate system in effect for the Printer object. Use TextHeight to determine the amount of vertical space that is required to display the text. The height returned includes the correct leading space above and below the text. Therefore, you can use the height to calculate the positions of multiple lines of text on a page.

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


Functions and objects in the Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic. In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework. They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework implementation.


The following example demonstrates the use of the TextHeight and TextWidth methods.

Dim Printer As New Printer
Dim msg As String = "String to measure"
Printer.Print(Printer.TextHeight(msg) & " by " & _
    Printer.TextWidth(msg) & " twips")

See Also

Printer Class
Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Namespace


Return to top