I have been toying with this code and seeking more information througout this forum but have come to the point where I cannot go further without some help.
I am trying to print a multi page output of an array of values. I cannot get a new blank page to appear for the second page of printed information.
Here is the code I have so far:
The second page seems to print over the first.
Is there something wrong with this code?
I have checked everywhere for some resources on this subject but it is extremely scarce.
Can anyone help??
I am trying to print a multi page output of an array of values. I cannot get a new blank page to appear for the second page of printed information.
Here is the code I have so far:
Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim Term As Integer = tbxTerm.Text
Dim results(Term) As Double
Dim Repayment As Double = tbxRepayment.Text
Dim Rate As Double = tbxRate.Text
Dim presValue As Double
Dim logo As New Bitmap("dib.bmp")
Dim i As Integer = 0
Dim y As Integer = 210
Dim x As Integer = 50
presValue = Repayment
'Page header information
e.Graphics.DrawImage(logo, 550, 50)
e.Graphics.DrawString("DIB Specialist Finance Line of Credit Calculator", _
New Font("Microsoft Sans Serif", 14, FontStyle.Bold), Brushes.Blue, 50, 50)
e.Graphics.DrawString("Line of Credit Chronology", _
New Font("Microsoft Sans Serif", 14, FontStyle.Bold), Brushes.Black, 50, 75)
e.Graphics.DrawString("Interest Rate = " & Rate & "%", _
New Font("Microsoft Sans Serif", 12, FontStyle.Bold), Brushes.Black, 50, 100)
e.Graphics.DrawString("Term = " & Term & " (months)", _
New Font("Microsoft Sans Serif", 12, FontStyle.Bold), Brushes.Black, 350, 100)
e.Graphics.DrawString("Repayment Amount = $" & Format(Repayment, "##,##0.00"), _
New Font("Microsoft Sans Serif", 12, FontStyle.Bold), Brushes.Black, 50, 120)
'calculated data to be printed possibly over more then one page
For i = 0 To (Term - 1)
results(i) = presValue * (1 + Rate / 1200) ^ (1)
presValue = results(i) + Repayment
e.Graphics.DrawString(" Month " & (i + 1) & " = $" & _
Format(Math.Round(results(i), 2), "#,###,##0.00") & " ", _
New Font("Microsoft Sans Serif", 12, FontStyle.Bold), Brushes.Black, x, y)
y += 20
If y > 1100 Then 'Print second column
y = 210
x = 450
End If
Next i
If Term > 90 Then ' data more than one page in length
y = 210
x = 50
e.HasMorePages = True
For i = 90 To (Term - 1)
results(i) = presValue * (1 + Rate / 1200) ^ (1)
presValue = results(i) + Repayment
e.Graphics.DrawString(" Month " & (i + 1) & " = $" & _
Format(Math.Round(results(i), 2), "#,###,##0.00") & " ", _
New Font("Microsoft Sans Serif", 12, FontStyle.Bold), Brushes.Black, x, y)
y += 20
If y > 1100 Then 'Print second column
y = 210
x = 450
End If
Next i
End If
e.HasMorePages = False
End Sub
The second page seems to print over the first.
Is there something wrong with this code?
I have checked everywhere for some resources on this subject but it is extremely scarce.
Can anyone help??