Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In VB6, what is the code to print a horizontal line on the paper print 1

Status
Not open for further replies.

Hiccup

Programmer
Jan 15, 2003
266
US
I'm using VB6 and I need to print a horizontal line on a report printout. The printout is a report and I would like to print the line under the Report title.

Can anyone tell me where to add the "Draw Line" code in the following:

Private Sub cmdPrintRecord_Click()
Screen.MousePointer = vbHourglass
Printer.FontName = "MS Sans Serif"
Printer.FontSize = 16
Printer.FontBold = True
Printer.Orientation = 2
Printer.PaperSize = vbPRPSLegal 'Use Papersize = 3 (or vbPRPSTabloid) for 11X17 paper.)
Printer.Print: Printer.Print 'Skip 2 lines
Printer.Print vbNewLine & Space(61) & "oCCM MODELING DATABASE"
Printer.FontSize = 10
Printer.Print Space(128) & Format(Date)

'(I WOULD LIKE THE HORIZONTAL LINE PRINTED HERE ON THE REPORT)

Printer.EndDoc
Beep
Screen.MousePointer = vbDefault
MsgBox ("Print Completed!")
End Sub

Any help would be greatly appreciated!
 
Hiccup,

Printer.Line(0,Printer.CurrentY)-(Printer.ScaleWidth,Printer.CurrentY)

should do it..

Regards Hugh
 
Thanks, HughLerwill and here's a star for your help!!
 
HughLerwill, I tried the code and did get a printed line, however I'm not getting it to print where I want it. Can you tell me what to put in your code example if I want a "Bold" Line to print 2 inches from the top and 1 inch in on both the left and right margins of a letter-size page.

Thanks!
 
Hiccup,

The following is untested but its going to be something like;

dim oldScaleMode as Integer
oldScaleMode=Printer.ScaleMode

Printer.ScaleMode = vbInches
Printer.Line (1, 2)-(Printer.ScaleWidth - 1, 2)

Printer.ScaleMode = oldScaleMode

Checkout VB help for the Line Method and ScaleMode property.

regards Hugh
 
Thanks again, HughLerWill and here's another star for that tip!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top