The code below will draw a box around text printed. Note that at the end of each printer.print line that has text there is a ";" this is to hold the printer position to get the printer.CurrentX position.
The If Printer.CurrentX > EndX is used to insure that the longest line of text is inclosed in the box
Dim StartX As Single
Dim EndX As Single
Dim StartY As Single
Dim EndY As Single
Private Sub Command1_Click()
Printer.FontSize = 20
StartX = Printer.CurrentX
StartY = Printer.CurrentY
Printer.Print "Hello World";
EndX = Printer.CurrentX
Printer.Print
Printer.Print "This Will Draw A Box";
if Printer.CurrentX > EndX then EndX = Printer.CurrentX
Printer.Print
Printer.Print "Around the Text Printed";
if Printer.CurrentX > EndX then EndX = Printer.CurrentX
Printer.Print
EndY = Printer.CurrentY
Printer.Line (StartX, StartY)-(EndX, EndY), , B
Printer.EndDoc
End Sub