need help with this(printdocument method)

niea_186

New member
Joined
Nov 27, 2008
Messages
1
Programming Experience
1-3
hi, i'm new here and new at VB.net. I just want to ask why this is happening to me. I'm doing a short report for my program and i suppose to print it out using printdocument. my problem is, i can't get my VB print to the second page. I've done a lot of research but in the end my coding just print out the same page over and over again.

eg suppose VB print out the second page but it print out page 1 again without printing out the second page.

this is my coding

VB.NET:
    Private Sub PrintDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument.PrintPage
        Dim printFont As New Font("Times New Roman", 12)
        Dim headingFont As New Font("Century Gothic", 14, FontStyle.Bold)
        Dim headingFont1 As New Font("Century Gothic", 16, FontStyle.Bold)
        Dim lineHeightSingle As Single = printFont.GetHeight + 30
        Dim horizontalPrintLocationSingle As Single = e.MarginBounds.Left
        Dim verticalPrintLocationSingle As Single = e.MarginBounds.Top
        Dim printLineString As String

        printLineString = "Malay Cultural Club, University College Sedaya International" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont1, Brushes.Black, horizontalPrintLocationSingle, _
        verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        printLineString = "Introduction" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, _
        verticalPrintLocationSingle)
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, _
        verticalPrintLocationSingle)

        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "The Malay Culture Club of University College Sedaya International was recently revived on " & ControlChars.NewLine _
        & "28th January, 2007. The objective of this club is to introduce the Malay culture to the students " & ControlChars.NewLine _
        & "of University College Sedaya International and the club is opened to all students of University " & ControlChars.NewLine _
        & "College Sedaya International regardless of their race and nationality. 
        e.Graphics.DrawString(printLineString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Event Name" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Date/Time/Vanue of Event" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)

        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Date  : " & ControlChars.NewLine & "Time  : " & ControlChars.NewLine & "Vanue : "
        e.Graphics.DrawString(printLineString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle

        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        verticalPrintLocationSingle += lineHeightSingle
        printLineString = "Goals/Objective" & ControlChars.NewLine & " "
        e.Graphics.DrawString(printLineString, headingFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        verticalPrintLocationSingle += lineHeightSingle


        --this part not sure--
        if pageCounterInteger <= 4 Then
        e.HasMorePages = True
        Else
        e.HasMorePages = False
        pageCounterInteger = 1
        End If

    End Sub

my not sure how to use the HasMorePages coding
please ignore some of the coding because this is only sample and it is not complete. i just want to see either my coding works or not .

Please help me with this problem
 
Back
Top