Printing With Vb6 - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Printing With Vb6 (8165 Views)
| Printing With Vb6 by yaro248(op): 1:59am On May 31, 2007 |
hi, can anyone help me with the code to print with vb6? I am writing a program to print some text but have no idea on how to do that. I can load my printers anyway using my Common Dialogue Control. |
| Re: Printing With Vb6 by Fdeveloper(m): 4:26pm On May 31, 2007 |
Unfortunetaly, printing is somewhat cumbersome with VB6 but I hope he following sample gives you an idea of how to go about it Private Sub cmdPrint_Click() On Error GoTo PrintClickError 'Prompt the user to select a printer Printer.EndDoc Printer.TrackDefault = True frmMDIAdmin!dlgMDI.PrinterDefault = True ' Note the Dialog control referenced here is in a seperate MDI form frmMDIAdmin!dlgMDI.Flags = cdlPDNoPageNums Or cdlPDNoSelection frmMDIAdmin!dlgMDI.CancelError = True frmMDIAdmin!dlgMDI.ShowPrinter Printer.Font = "Arial" Printer.FontBold = True Printer.FontSize = 16 Printer.FontItalic = False Printer.CurrentX = (2 + (96 - Printer.TextWidth("This is the title of the page" )) / 2Printer.Print "This is the title of the page" Printer.Print 'Column Headings Printer.FontSize = 11 Printer.FontBold = True Printer.CurrentX = 2 Printer.Print "First"; Printer.CurrentX = 35 Printer.Print "Second"; Printer.CurrentX = 45 Printer.Print "Third"; Printer.CurrentX = 55 Printer.Print "Fourth" Printer.FontItalic = False Printer.FontSize = 10 Printer.FontBold = False Printer.EndDoc DoEvents Exit Sub PrintClickError: Exit Sub End Sub |
| Re: Printing With Vb6 by yaro248(op): 11:15pm On Jun 02, 2007 |
Thanks FDeveloper, I'm grateful. But what does CurrentX for the Printer Object mean? |
| Re: Printing With Vb6 by Fdeveloper(m): 6:32pm On Jun 03, 2007 |
The printer properties .CurrentX and .CurrentY are used to set the current print position on a page where .CurrentX refers to a column and CurrentY refers to a row. Imagine that you are printing on a page that has 50 lines and each line can contain 80 characters, since you most likely don't intend to print every character on every line, you use .CurrentY to set the row (i.e. Line) that you want to print on and .CurrentX to set the column. So in my example, you can see where I increase the .CurrentX value to print column headings. |
| Re: Printing With Vb6 by yaro248(op): 11:33pm On Jun 26, 2007 |
yaeh, thanks. been really helpful. I also used the Printer Object. |
Login Code In Vb6.0 • Install Vb6 Application On Android • Help me convert this Vb6.0 code To Vb.net • 2 • 3 • 4
Data Analyst/science - The Smart Way To Learn And Be Effective • A Site That Requires No Internet Connection To Surf! • Help me convert this Vb6.0 code To Vb.net
)) / 2