Printing Multiple Unique Pages - VB.net

ahayes1ic

New member
Joined
Sep 30, 2003
Messages
4
I am now unable to edit my prior post so here is an update.

Here is a simpler version of code that I would like to have print 1 line on a new page for ten pages.

Unfortunately all I get is the text overwriting all on the first page.

Code:
Option Explicit On 

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub btnPrint_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles _
btnPrint.Click
        PrintPreviewDialog1.ShowDialog()
    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
        Dim i As Integer

        For i = 0 To 10
            e.Graphics.DrawString("Line of Credit Chronology" & i, _
            New Font("Microsoft Sans Serif", 14, FontStyle.Bold), _
Brushes.Black, 50, 75 )
            If i < 10 Then
                e.HasMorePages = True
            Else
                e.HasMorePages = False
            End If
        Next i

    End Sub

End Class

Can anyone tell me what I am doing wrong or right?

How do I get a clean blank page to print new data?
 
Last edited by a moderator:
You dont want to have a loop there, for a start. Youll have to keep a form-scoped variable around saying which number to print. Like youre doing now youll write the text, then if i < 10 then tell it it has more pages. Youll have to manually increment it each time too.
 
Back
Top