Printer.TextWidth Method (String)
Returns the width 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)
Syntax
public float TextWidth(
string text
)
public:
float TextWidth(
String^ text
)
member TextWidth :
text:string -> float32
Public Function TextWidth (
text As String
) As Single
Parameters
text
Type: System.StringThe String to be measured.
Return Value
Type: System.Single
Returns a Single
Remarks
The width 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 TextWidth to determine the amount of horizontal space that is required to display the text. If the string contains embedded carriage returns, TextWidth returns the width of the longest line.
Note
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.
Examples
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")
Printer.EndDoc()
See Also
Printer Class
Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Namespace
7f9351ea-cb3e-4615-8f70-5a29c165c1a7bc1bcb98-e13b-4c68-a514-045c042dbf364e434922-3709-49c6-a69d-38120ed72d7a
Return to top