Printing Pages Problem

robertlbryant

New member
Joined
Sep 28, 2009
Messages
2
Location
Danville, IL
Programming Experience
1-3
I have been struggling with printing multiple pages from a list box. It seems to go fine for a page, but then the index seems to reset to 0 when I step through with the debugger, causing each page to be an exact copy of the first page. Can anyone spot why this would happen in my loop?

VB.NET:
                Do
                    strPrintLine = CStr(lstGames.Items(intListIndex))
                    e.Graphics.DrawString(strPrintLine, fntPrintFont, _
                    Brushes.Black, sngPrintX, sngPrintY)
                    sngPrintY += sngLineHeight
                    intListIndex += 1

                    If sngPrintY > e.PageBounds.Bottom - 40 Then

                        If page < numPages Then
                            e.HasMorePages = True
                            page += 1
                            Return
                        Else
                            e.HasMorePages = False
                            Return
                        End If
                    End If

                Loop Until intListIndex = intGamesMax
 

SlyBoots

New member
Joined
Sep 28, 2009
Messages
4
Programming Experience
Beginner
first of all, how are declared page and intListIndex? Those variable should be global(i mean out of the print sub) or static, Otherwise, they will be re-initialized
 

robertlbryant

New member
Joined
Sep 28, 2009
Messages
2
Location
Danville, IL
Programming Experience
1-3
Ah, thank you SlyBoots! I had intListIndex in a Dim rather than Static. Works like a charm now. I only had one year of VB.NET years and years ago, so I guess there are quite a few things I need to learn/re-learn haha

Thanks again!
 
Top Bottom