Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,333 members, 7,808,162 topics. Date: Thursday, 25 April 2024 at 07:57 AM

Printing With Vb6 - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Printing With Vb6 (8006 Views)

Login Code In Vb6.0 / Install Vb6 Application On Android / Help me convert this Vb6.0 code To Vb.net (2) (3) (4)

(1) (Reply) (Go Down)

Printing With Vb6 by yaro248(m): 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"wink)) / 2
   Printer.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(m): 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(m): 11:33pm On Jun 26, 2007
yaeh, thanks. been really helpful. I also used the Printer Object.

(1) (Reply)

Cnc Cad/cam Programmer / Programming In Asterix / Java Whatsapp Group Rebranded

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.