Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2006, 02:54 PM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old September 18th, 2006, 05:13 AM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anyone? Any idea?

Do you think I have to re-install VB on my computer? Because if a code runs well, it has to do allways the same! But in this case, every time I run the program, it does something diferent!

Lucas Pasquali





Similar Threads
Thread Thread Starter Forum Replies Last Post
Does anyone have an example. Printing fbailey VS.NET 2002/2003 0 December 9th, 2006 06:03 PM
validate.asp problems and logon.asp problems p2ptolu Classic ASP Databases 0 February 16th, 2005 02:34 PM
capturing printing settings when printing reports nikolaosk Access VBA 0 February 8th, 2005 04:14 AM
crystal rep printing problems in win NT nilesh_parmar Crystal Reports 0 December 21st, 2004 05:57 AM
Printing NiNe ADO.NET 5 April 7th, 2004 04:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.