Printing problems
Hi everyone!
I'm with some problems printing in VBE 2005. I have the following code:
Public Class Form1
Dim font5 As New Font("Arial", 5)
Dim font8 As Font = New Font("Arial", 8)
Dim font10 As Font = New Font("Arial", 10)
Dim font12 As Font = New Font("Arial", 12)
Dim font15 As Font = New Font("Arial", 15)
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
Me.NumericUpDown1.Maximum = 4
Me.NumericUpDown1.Minimum = 2
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim objFont As New Font("Verdana", 16, GraphicsUnit.Point)
Static intPageNum As Integer
intPageNum += 1
Select Case intPageNum
Case 1
e.Graphics.DrawImage(My.Resources.ColunasRDB, e.Graphics.VisibleClipBounds)
e.Graphics.DrawString("PAGE " & intPageNum.ToString, objFont, Brushes.Black, 600, 1000)
e.Graphics.DrawRectangle(Pens.Black, 0, 0, 600, 100)
e.Graphics.DrawString("Pinting with Visual Basic Express", objFont, Brushes.Black, 10, 10)
Case 2
e.Graphics.DrawImage(My.Resources.TravessaRDB, e.Graphics.VisibleClipBounds)
e.Graphics.DrawString("PAGE " & intPageNum.ToString, objFont, Brushes.Black, 600, 1000)
e.Graphics.DrawRectangle(Pens.Black, 0, 0, 600, 100)
e.Graphics.DrawString("Pinting with Visual Basic Express", objFont, Brushes.Black, 10, 10)
Case 3
e.Graphics.DrawImage(My.Resources.AcessorioRDB, e.Graphics.VisibleClipBounds)
e.Graphics.DrawString("PAGE " & intPageNum.ToString, objFont, Brushes.Black, 600, 1000)
e.Graphics.DrawRectangle(Pens.Black, 0, 0, 600, 100)
e.Graphics.DrawString("Pinting with Visual Basic Express", objFont, Brushes.Black, 10, 10)
Case 4
e.Graphics.DrawImage(My.Resources.PecasRDB, e.Graphics.VisibleClipBounds)
e.Graphics.DrawString("PAGE " & intPageNum.ToString, objFont, Brushes.Black, 600, 1000)
e.Graphics.DrawRectangle(Pens.Black, 0, 0, 600, 100)
e.Graphics.DrawString("Pinting with Visual Basic Express", objFont, Brushes.Black, 10, 10)
End Select
If intPageNum < 4 Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub
Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintDialog1.ShowDialog()
End Sub
End Class
When I first run this code, I got 4 pages printed, just like I wanted. But, the second time I run the program, it only printed the first page. And after some trying, now it only prints one blank page!!!
No matter what I do, I can't get the code to print correctly.
Anyone knows what could I do to solve this?
Thanks,
Lucas
Lucas Pasquali
|