Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2008 printing multiple pages

$
0
0
So, this printing thing is blowing my mind. I work for a lab and want to print samples that are analyzed for dye. If I print one at a time by typing the sample numbers in one at a time and print each time, it works fine, but when I implement my code to print a range of sample charts, they all print on the same page on top of each other.

coming into this, I have the samples that I want to print stored in a file called getsamps.tmp, and at the beggining of the code I use a loop to store the samples into an array.

here is my code:
Public Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim autoScaleFileName As String = "" ' this string represents the file name for the autoscale graph
Dim graphFileName As String = "" ' this string represents the file name for the regular graph
Dim temp As String
Dim i As Integer
Dim tab1(No_Records - 1) As String
'Dim graphFileName As String

If printMultipleCharts = True Then
i = 0
Dim getSampsObjectReader As New System.IO.StreamReader(Sample_List_File)
Do Until getSampsObjectReader.EndOfStream ' character on the keyboard could be used for imputing sample data.
For i = 0 To No_Records - 1
tab1(i) = getSampsObjectReader.ReadLine()
Next
Loop
getSampsObjectReader.Close()

If frmPrintMultipleCharts.opt1ChartPerPage.Checked Then
For i = 0 To UBound(tab1)
graphFileName = tab1(i)
'temp = Sample_File_Name(tab1(i)) ' for the case that we are printing multiple charts
graphFileName = Mid(graphFileName, 1, Len(graphFileName) - 3) & "HGL"
printGraph = True
printPage(e, graphFileName, "graph", 95, 100, 160, 80, 18, 600, 450, 12)
' e.HasMorePages = True
If frmPrintMultipleCharts.chkPrintAutoscales.Checked Then
autoScaleFileName = Mid(graphToPrint, 1, Len(graphToPrint) - 3) & "HGC"
If My.Computer.FileSystem.FileExists(autoScaleFileName) Then
printAutoScale = True
printPage(e, autoScaleFileName, "autoscale", 95, 100, 160, 80, 18, 600, 450, 12)
End If
End If
Next
Exit Sub
End If

If frmPrintMultipleCharts.opt2ChartsPerPage.Checked Then

End If

If frmPrintMultipleCharts.opt4ChartsPerPage.Checked Then

End If



Now, the user has the option to print one per page, of the different sample range they selected, 2 per page, or 4 per page. I haven't written the code for 2 or 4 per page yet. I thought about using the e.hasMorePages property, but that gets me into an infinite loop. I read that this has to be called outside of the .printPage sub, but I would like to be able to do it the way I am currently.

adam

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>