Question print ?

web4

Member
Joined
Mar 28, 2009
Messages
16
Programming Experience
Beginner
VB.NET:
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As  _
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        'PrintPage is the foundational printing event. This event gets fired for every
        ' page that will be printed
        Static intCurrentChar As Int32
        ' declaring a static variable to hold the position of the last printed char
        Dim font As New Font("Verdana", 14)
        ' initializing the font to be used for printing
        Dim PrintAreaHeight, PrintAreaWidth, marginLeft, marginTop As Int32
        With PrintDocument1.DefaultPageSettings
            ' initializing local variables that contain the bounds of the printing area rectangle
            PrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
            PrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
            ' initializing local variables to hold margin values that will serve
            ' as the X and Y coordinates for the upper left corner of the printing
            ' area rectangle.
            marginLeft = .Margins.Left
            marginTop = .Margins.Top
            ' X and Y coordinate
        End With

        If PrintDocument1.DefaultPageSettings.Landscape Then
            Dim intTemp As Int32
            intTemp = PrintAreaHeight
            PrintAreaHeight = PrintAreaWidth
            PrintAreaWidth = intTemp
            ' if the user selects landscape mode, swap the printing area height and width
        End If

        Dim intLineCount As Int32 = CInt(PrintAreaHeight / font.Height)
        ' calculating the total number of lines in the document based on the height of
        ' the printing area and the height of the font
        Dim rectPrintingArea As New RectangleF(marginLeft, marginTop, PrintAreaWidth, PrintAreaHeight)
        ' initializing the rectangle structure that defines the printing area
        Dim fmt As New StringFormat(StringFormatFlags.LineLimit)
        'instantiating the StringFormat class, which encapsulates text layout information
        Dim intLinesFilled, intCharsFitted As Int32
        e.Graphics.MeasureString(Mid(RichTextBox1.Text, intCurrentChar + 1), font, _
New SizeF(PrintAreaWidth, PrintAreaHeight), fmt, intCharsFitted, intLinesFilled)
        ' calling MeasureString to determine the number of characters that will fit in
        ' the printing area rectangle
        e.Graphics.DrawString(Mid(RichTextBox1.Text, intCurrentChar + 1), font, _
Brushes.Black, rectPrintingArea, fmt)
        ' print the text to the page
        intCurrentChar += intCharsFitted
        'advancing the current char to the last char printed on this page
< TextBox1.Text.Length Then  'HERE'S THE ERROR PART

If intCurrentChar e.HasMorePages=True  'HERE'S ALSO THE ERROR PART
            'HasMorePages tells the printing module whether another PrintPage event should be fired
        Else
            e.HasMorePages = False
            intCurrentChar = 0
        End If
End Sub


anybody please help me in correcting erros on that code i've already provided a comment on where the error is.....sorry if i don't know english so much...honestly i've search that on the net so that i could not ask here and don't disturb anybody because of my noobness but it has still errors on my compiler VB2008 express edition....pls help me...btw here the original link to that code Printing in VB .NET - Print Dialog, PrintPreview Dialog, PrintPreview Sample Code Control, PageSetup Dialog thanks
 
Last edited by a moderator:
Moved. The VS.NET forums are for IDE problems, not language problems.

You've said that there are errors but you haven't actually told us what those errors are. Are there error messages? Does something happen that shouldn't? Does something not happen that should? You should always provide a FULL and CLEAR description.
 
Back
Top