none
Continue printing if not all has been printed

    Question

  • Hello! I am working on a simple program that prints off numbers. The number of numbers varies <g class="gr_ gr_43 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="43" id="43">on</g> the user. I will say have <g class="gr_ gr_92 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-del replaceWithoutSep" data-gr-id="92" id="92">a 1000</g> numbers needing to be printed but prints only one page that has 779 of the 1000 numbers needing printing. Here is my code that matters 
        Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
            Dim font As New Font("Times New Roman", 12, FontStyle.Regular)
            'Possible new Solution!
            e.Graphics.DrawString(rtbVerticalText.Text & vbNewLine & "Incremented By: " & increment, font, Brushes.Black, New Rectangle(50, 60, 700, 1000))
        End Sub
    I tried using e.HasMorePages = True but that just kept printing pages so I am not entirely sure how that works. Please help! Thanks!!!
    • Edited by Dragnorian Wednesday, April 26, 2017 10:22 PM Error
    Wednesday, April 26, 2017 10:21 PM

All replies

  • I tried using e.HasMorePages = True but that just kept printing pages so I am not entirely sure how that works.

    You have to keep track of where you are up to in the printing. Then there are two steps to the process.  Firstly, test where you are up to and decide whether there are more pages or not.  Then, if there are more pages, set e.HasMorePages and update whatever you use as the indicator of where that next page has to start in the printing. From your code, it would be something like:

    If Increment < PageCountTotal then
       e.HasMorePages = True
       Increment += 1
    Else
        e.HasMorePages = False
    End If
    If you are printing more than one value per page (you mention 799) then that is the number that you have to increment by.


      
    Wednesday, April 26, 2017 10:40 PM