View the step-by-step solution to:

Public Class Form1 Dim connStr As String = "Provider=Microsoft.OLEDB.0;" & _ "Data Source=GRADEBOOK.MDB" Dim sqlStr As String...

i need to build a grade for class. using vb the grade book has 2 tables. one contains ss # first exam second exam and final exam i need to fill a letter with the first and last name
street address
city state zip
dear student
your grades for class# are as follow
final exam : (grade)
semester grade: (a or b or c or f )
best wishes
prof jones
the part i am stuck on is the assignment of letter grade to the number grade. and output of the letter here is my code

i have attached my code in notepad
Public Class Form1 Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=GRADEBOOK.MDB" Dim sqlStr As String = "SELECT * FROM Grades" Dim dt As New DataTable() Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click dt.Clear() Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr) dataAdapter.Fill(dt) dataAdapter.Dispose() dgvDisplay.DataSource = dt End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim changes As Integer Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr) Dim commandBuilder As New OleDb.OleDbCommandBuilder(dataAdapter) changes = dataAdapter.Update(dt) dataAdapter.Dispose() End Sub Private Sub btnSemesterAvg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSemesterAvg.Click UpdateGrid("SELECT lastName,firstName, ((firstExam+secondExam+2*finalExam)/4) AS semesterAverage FROM Students INNER JOIN Grades ON Students.socSecNumber = Grades.socSecNumber") End Sub Sub UpdateGrid(ByVal sqlStr As String) Dim dt As New DataTable() Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=GRADEBOOK.MDB" Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr) dataAdapter.Fill(dt) dataAdapter.Dispose() dgvDisplay.DataSource = dt End Sub Private Sub btnDoorPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoorPost.Click UpdateGrid("SELECT Students.socSecNumber, ((firstExam+secondExam+2*finalExam)/4) AS semesterAverage FROM Students INNER JOIN Grades ON Students.socSecNumber = Grades.socSecNumber") End Sub Private Sub StudentGradeLetter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim StudentGradeLetter As New DataTable Dim FmtStr As String = "{0, -10}{1, 10}" Dim sqlStr As String Dim ID As String sqlStr = "Select socSecNumber, firstExam, secondExam, finalExam, Round(firstExam + secondExam + (2*finalExam)/4,1) as Average From Grades Order By (firstExam + secondExam + (2*finalExam)/4) DESC" Dim DataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr) DataAdapter.Fill(StudentGradeLetter) DataAdapter.Dispose() For Index As Integer = 0 To StudentGradeLetter.Rows.Count - 1 ID = StudentGradeLetter.Rows(Index)("socSecNumber").ToString Index += 1 ReDim Preserve Record(Index)
Background image of page 1
Record(Index).ID = ID.Substring(7, 4) Record(Index).Average = (CDbl(StudentGradeLetter.Rows(Index) ("FirstExam")) _ + CDbl(StudentGradeLetter.Rows(Index) ("secondExam")) _ + CDbl(StudentGradeLetter.Rows(Index) ("finalExam")) * 2) / 4 Record(Index).Letter = GetLetterGrade(Record(Index).Average) Next End Sub Public Function GetLetterGrade(ByVal semesterAverage As String) As String Dim thirdfield As Integer thirdfield = semesterAverage.IndexOf(" ") semesterAverage = semesterAverage.Substring(3, thirdfield) Return semesterAverage Select Case semesterAverage Case Is >= 90 : Return "A" Case Is >= 80 : Return "B" Case Is >= 70 : Return "C" Case Is >= 60 : Return "D" Case Else : Return "F" End Select End Function End Class
Background image of page 2

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question