I am trying to print the content in my listbox after the program is run (The courses that are typed in, Total hours, Quantity Points, Total GPA). It is opening up my printer options but printing a blank page every time...
Any assistance is appreciated!
Code:
Public Class Form1
Dim QualityPoints As Double
Dim CourseName, hours As String
Private Sub btnTotalHours_Click(sender As Object, e As EventArgs) Handles btnTotalHours.Click
txtBoxTotalHours.Text = NumericUpDown1.Value + NumericUpDown2.Value + NumericUpDown3.Value + NumericUpDown4.Value + NumericUpDown5.Value + NumericUpDown6.Value + NumericUpDown7.Value + NumericUpDown8.Value
End Sub
Private Sub btnTotalQualityPoints_Click(sender As Object, e As EventArgs) Handles btnTotalQualityPoints.Click
Select Case txtBoxGrade1.Text
Case "A"
QualityPoints += (4 * NumericUpDown1.Value)
Case "B"
QualityPoints += (3 * NumericUpDown1.Value)
Case "C"
QualityPoints += (2 * NumericUpDown1.Value)
Case "D"
QualityPoints += (1 * NumericUpDown1.Value)
Case "F"
QualityPoints += (0 * NumericUpDown1.Value)
Case " "
QualityPoints += (0 * NumericUpDown1.Value)
End Select
Select Case txtBoxGrade2.Text
Case "A"
QualityPoints += (4 * NumericUpDown2.Value)
Case "B"
QualityPoints += (3 * NumericUpDown2.Value)
Case "C"
QualityPoints += (2 * NumericUpDown2.Value)
Case "D"
QualityPoints += (1 * NumericUpDown2.Value)
Case "F"
QualityPoints += (0 * NumericUpDown2.Value)
Case " "
QualityPoints += (0 * NumericUpDown2.Value)
End Select
Select Case txtBoxGrade3.Text
Case "A"
QualityPoints += (4 * NumericUpDown3.Value)
Case "B"
QualityPoints += (3 * NumericUpDown3.Value)
Case "C"
QualityPoints += (2 * NumericUpDown3.Value)
Case "D"
QualityPoints += (1 * NumericUpDown3.Value)
Case "F"
QualityPoints += (0 * NumericUpDown3.Value)
Case " "
QualityPoints += (0 * NumericUpDown3.Value)
End Select
Select Case txtBoxGrade4.Text
Case "A"
QualityPoints += (4 * NumericUpDown4.Value)
Case "B"
QualityPoints += (3 * NumericUpDown4.Value)
Case "C"
QualityPoints += (2 * NumericUpDown4.Value)
Case "D"
QualityPoints += (1 * NumericUpDown4.Value)
Case "F"
QualityPoints += (0 * NumericUpDown4.Value)
Case " "
QualityPoints += (0 * NumericUpDown4.Value)
End Select
Select Case txtBoxGrade5.Text
Case "A"
QualityPoints += (4 * NumericUpDown5.Value)
Case "B"
QualityPoints += (3 * NumericUpDown5.Value)
Case "C"
QualityPoints += (2 * NumericUpDown5.Value)
Case "D"
QualityPoints += (1 * NumericUpDown5.Value)
Case "F"
QualityPoints += (0 * NumericUpDown5.Value)
Case " "
QualityPoints += (0 * NumericUpDown5.Value)
End Select
Select Case txtBoxGrade6.Text
Case "A"
QualityPoints += (4 * NumericUpDown6.Value)
Case "B"
QualityPoints += (3 * NumericUpDown6.Value)
Case "C"
QualityPoints += (2 * NumericUpDown6.Value)
Case "D"
QualityPoints += (1 * NumericUpDown6.Value)
Case "F"
QualityPoints += (0 * NumericUpDown6.Value)
Case " "
QualityPoints += (0 * NumericUpDown6.Value)
End Select
Select Case txtBoxGrade7.Text
Case "A"
QualityPoints += (4 * NumericUpDown7.Value)
Case "B"
QualityPoints += (3 * NumericUpDown7.Value)
Case "C"
QualityPoints += (2 * NumericUpDown7.Value)
Case "D"
QualityPoints += (1 * NumericUpDown7.Value)
Case "F"
QualityPoints += (0 * NumericUpDown7.Value)
Case " "
QualityPoints += (0 * NumericUpDown7.Value)
End Select
Select Case txtBoxGrade8.Text
Case "A"
QualityPoints += (4 * NumericUpDown8.Value)
Case "B"
QualityPoints += (3 * NumericUpDown8.Value)
Case "C"
QualityPoints += (2 * NumericUpDown8.Value)
Case "D"
QualityPoints += (1 * NumericUpDown8.Value)
Case "F"
QualityPoints += (0 * NumericUpDown8.Value)
Case " "
QualityPoints += (0 * NumericUpDown8.Value)
End Select
txtBoxTotalQualityPoints.Text = QualityPoints
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtBoxCourse1.Clear()
txtBoxCourse2.Clear()
txtBoxCourse3.Clear()
txtBoxCourse4.Clear()
txtBoxCourse5.Clear()
txtBoxCourse6.Clear()
txtBoxCourse7.Clear()
txtBoxCourse8.Clear()
txtBoxGrade1.Clear()
txtBoxGrade2.Clear()
txtBoxGrade3.Clear()
txtBoxGrade4.Clear()
txtBoxGrade5.Clear()
txtBoxGrade6.Clear()
txtBoxGrade7.Clear()
txtBoxGrade8.Clear()
txtBoxTotalGPA.Clear()
txtBoxTotalHours.Clear()
txtBoxTotalQualityPoints.Clear()
NumericUpDown1.Value = 0
NumericUpDown2.Value = 0
NumericUpDown3.Value = 0
NumericUpDown4.Value = 0
NumericUpDown5.Value = 0
NumericUpDown6.Value = 0
NumericUpDown7.Value = 0
NumericUpDown8.Value = 0
lstBoxResults.Items.Clear()
End Sub
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim semester As String
Dim totalGPA As Double = QualityPoints / txtBoxTotalHours.Text
semester = CStr(lstBoxResults.Text)
txtBoxTotalGPA.Text = CStr(totalGPA)
txtBoxTotalGPA.Text = Math.Round(totalGPA, 3)
If radButtonFall.Checked Then
semester = "Fall"
ElseIf radButtonSpring.Checked Then
semester = "Spring"
ElseIf radButtonSummer.Checked Then
semester = "Summer"
End If
lstBoxResults.Items.Add(semester & " " & "Semester : ")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Total Hours : " & txtBoxTotalHours.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Total Qualit Points : " & txtBoxTotalQualityPoints.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Total " & semester & " " & "GPA : " & txtBoxTotalGPA.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Enrolled Courses : ")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse1.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse2.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse3.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse4.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse5.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse6.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse7.Text)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add(txtBoxCourse8.Text)
End Sub
Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click
End
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim font1 As New Font("Arial", 16, FontStyle.Regular)
e.Graphics.DrawString(lstBoxResults.Text, font1, Brushes.Black, 100, 100)
End Sub
Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
PrintDialog1.ShowDialog()
PrintDocument1.Print()
End Sub
End Class