Printing With Vb6

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 22, 2009, 05:29 PM
430865 members and 297958 Topics
Latest Member: chiksy
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 1470 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.
 The Future In Software Development  Who Wants to Start an Electronic Game Development Company?  Java Or C++  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

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

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.