Printing With Vb6

A Member? Please Login  
type your username and password to login
Date: October 14, 2008, 06:57 PM
249906 members and 148598 Topics
Latest Member: voicemail
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Printing With Vb6
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Printing With Vb6  (Read 650 views)
yaro248 (m)
Printing With Vb6
« on: May 31, 2007, 01:59 AM »

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.
Fdeveloper (m)
Re: Printing With Vb6
« #1 on: May 31, 2007, 04:26 PM »

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"))) / 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
yaro248 (m)
Re: Printing With Vb6
« #2 on: June 02, 2007, 11:15 PM »

Thanks FDeveloper, I'm grateful. But what does CurrentX for the Printer Object mean?
Fdeveloper (m)
Re: Printing With Vb6
« #3 on: June 03, 2007, 06:32 PM »

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.
yaro248 (m)
Re: Printing With Vb6
« #4 on: June 26, 2007, 11:33 PM »

yaeh, thanks. been really helpful. I also used the Printer Object.
 Programmer Wanted For Mobile Solution  E-banking Solution  SQL And MySQL  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.