ERROR:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
I have tried to put the testscores array in a for next loop inside the student structure array, both between the student names and averages, after both of them, used a for each loop, even tried to use a 'with' student statement.
'This gets the the header, column heads, the student names and the averages printing when I click
Private Sub pdPrint_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pdPrint.PrintPage
Dim intVertPos As Integer
'Print the Report header.
e.Graphics.DrawString("Student Test Scores Report", New Font("Courier New", 12, FontStyle.Bold), Brushes.Black, 140, 10)
'Print the current date and time.
e.Graphics.DrawString("Date and Time: " & Now.ToString(), New Font("Courier New", 12, FontStyle.Bold), Brushes.Black, 15, 38)
'Print the column headers.
e.Graphics.DrawString(String.Format("{0, 15} {1, 5} {2, 5} {3, 5} {4, 5} {5, 5} {6, 10} ",
"Student Name", "Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Average"),
New Font("Courier New", 12, FontStyle.Bold), Brushes.Black, 10, 66)
'Print the body of the report.
intVertPos = 90
For intCount = 0 To (student.Length - 1)
e.Graphics.DrawString(String.Format("{0, 15} {1, 45}",
student(intCount).strStudentName, student(intCount).dblAverage.ToString("n1")),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
intVertPos += 14
Next
End Sub
'These are the different things I have tried for the test arrays, this is what gets the error at the click event.
'Print the body of the report.
intVertPos = 90
For intCount = 0 To (student.Length - 1)
e.Graphics.DrawString(String.Format("{0, 15} ",
student(intCount).strStudentName),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
For intTest = 0 To (intMAX_NUMTESTS - 1)
e.Graphics.DrawString(String.Format("{0, 20} {1, 5} {2, 5} {3, 5} {4, 10} ",
student(intCount).dblTestscores(intTest).ToString),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
Next
e.Graphics.DrawString(String.Format("{0, 45} ",
student(intCount).dblAverage.ToString),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
intVertPos += 16
Next
'print testscores try 2
For Each intTest As Double student.dblTestscores
e.Graphics.DrawString(String.Format("{0, 20} {1, 5} {2, 5} {3, 5} {4, 5} ",
student(intCount).dblTestscores(intTest).ToString()),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
Next
'printscoresTry3
With student
For intCount = 0 To (student.Length - 1)
e.Graphics.DrawString(String.Format("{0, 15} {1, 45}",
student(intCount).strStudentName, student(intCount).dblAverage.ToString("n1")),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
For Each intTest As Double In dblTestscores
e.Graphics.DrawString(String.Format("{0, 20} {1, 5} {2, 5} {3, 5} {4, 5} ",
student(intCount).dblTestscores(intTest).ToString()),
New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, intVertPos)
Next
intVertPos += 14
Next
End With
THANKS

New Topic/Question
Reply



MultiQuote




|