Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Printing multiple pages in Viusal Basic .net each from a different source using Sub Routines

Printing multiple pages in Viusal Basic .net each from a different source using Sub Routines

Scheduled Pinned Locked Moved Visual Basic
helpcsharptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tbkfile
    wrote on last edited by
    #1

    First post here so please be patient, I wrote some software for the company that I work for in VB6 for Scheduling and quoting construction based projects and am upgrading to VB 2008, not a problem except for the printing, The user had several check boxes and option groups which related to which pages were printed, the first was a cover page, second page a preamble, third page list of doors etc all taken from different sources, in VB6 it was pretty simple to create a printer object (called myPrint) call the various page sub routines and to put it together example as below:

    Select Case True
    Case frmPrint.optAll(0).Value = True 'materials listing
    MyPrint.NewPage
    PProductListingA
    Case frmPrint.optAll(1).Value = True 'bill of quantities
    MyPrint.NewPage
    PBOQsA

    Obviously we've lost the NewPage which has been replaced with HasMorePages from within the PrintPage method, I've spent about a week now trying to call the various sub routines from within this and quite simply have hit a brick wall. Lots of examples on the web to point me in the right direction but they all seem to be based around a single block of text printed over various pages, help. I just need a pointer in the right direction.

    D 1 Reply Last reply
    0
    • T tbkfile

      First post here so please be patient, I wrote some software for the company that I work for in VB6 for Scheduling and quoting construction based projects and am upgrading to VB 2008, not a problem except for the printing, The user had several check boxes and option groups which related to which pages were printed, the first was a cover page, second page a preamble, third page list of doors etc all taken from different sources, in VB6 it was pretty simple to create a printer object (called myPrint) call the various page sub routines and to put it together example as below:

      Select Case True
      Case frmPrint.optAll(0).Value = True 'materials listing
      MyPrint.NewPage
      PProductListingA
      Case frmPrint.optAll(1).Value = True 'bill of quantities
      MyPrint.NewPage
      PBOQsA

      Obviously we've lost the NewPage which has been replaced with HasMorePages from within the PrintPage method, I've spent about a week now trying to call the various sub routines from within this and quite simply have hit a brick wall. Lots of examples on the web to point me in the right direction but they all seem to be based around a single block of text printed over various pages, help. I just need a pointer in the right direction.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I would think that you just pass the Graphics object in the print event args to the Sub that's going to render that particular page. You just have to check for which page your printing to know which Sub to call.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      T 1 Reply Last reply
      0
      • D Dave Kreskowiak

        I would think that you just pass the Graphics object in the print event args to the Sub that's going to render that particular page. You just have to check for which page your printing to know which Sub to call.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        T Offline
        T Offline
        tbkfile
        wrote on last edited by
        #3

        Thanks Dave, I've tried this in just about everyway that I can think, the problem is that each section could be a number of pages long and it seems that when I pass it as Printing.PrintPageEventArgs so that each sub routine can check to see if there are any more pages using HasMorePages, the event is fired from both within the subroutine and the main PrintPage routine! if I pass it as a Graphics object than there's no way of checking to see if it will fit on one page or how to add one if it needs more (the old VB6 way was easy)

        D 1 Reply Last reply
        0
        • T tbkfile

          Thanks Dave, I've tried this in just about everyway that I can think, the problem is that each section could be a number of pages long and it seems that when I pass it as Printing.PrintPageEventArgs so that each sub routine can check to see if there are any more pages using HasMorePages, the event is fired from both within the subroutine and the main PrintPage routine! if I pass it as a Graphics object than there's no way of checking to see if it will fit on one page or how to add one if it needs more (the old VB6 way was easy)

          D Offline
          D Offline
          Duncan Edwards Jones
          wrote on last edited by
          #4

          What I have done in this case (for example in the DataGrid printer class[^] and the Structured Print Document[^]) is to have each "data item" track how much of it is is left and throw a new page if there is more data to print.

          '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

          T 1 Reply Last reply
          0
          • D Duncan Edwards Jones

            What I have done in this case (for example in the DataGrid printer class[^] and the Structured Print Document[^]) is to have each "data item" track how much of it is is left and throw a new page if there is more data to print.

            '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

            T Offline
            T Offline
            tbkfile
            wrote on last edited by
            #5

            Thanks Duncan - Its taken a while to sort out the logic, but like most things in VB once you have, you wonder why you didn't think of it before. Anyway its all sorted now so thnks for your help.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups