The document contains source code for a Visual Basic program that allows a user to input student names and scores into a data grid, calculates the total score, highest score, lowest score, and average score. The code uses arrays to store the student names and scores, and buttons to trigger calculations and output of the highest, lowest, and average scores.
The document contains source code for a Visual Basic program that allows a user to input student names and scores into a data grid, calculates the total score, highest score, lowest score, and average score. The code uses arrays to store the student names and scores, and buttons to trigger calculations and output of the highest, lowest, and average scores.
The document contains source code for a Visual Basic program that allows a user to input student names and scores into a data grid, calculates the total score, highest score, lowest score, and average score. The code uses arrays to store the student names and scores, and buttons to trigger calculations and output of the highest, lowest, and average scores.
Private student_name() As String Private student_score() As Integer Private total_score As Integer Private count As Integer Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load DataGridView1.Columns.Add("Column1", "Student Name") DataGridView1.Columns.Add("Column2", "Student Score") End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim name As String = InputBox("Please Enter Student Name: ").ToUpper() Dim score As Integer = Integer.Parse(InputBox("Please Enter Student Score for " & name & ": ")) DataGridView1.Rows.Add(name, score.ToString) count += 1 total_score += score ReDim Preserve student_name(count - 1) ReDim Preserve student_score(count - 1) student_name(count - 1) = name student_score(count - 1) = score End Sub
Private Sub btnHighest_Click(sender As Object, e As EventArgs) Handles
btnBest.Click Dim highest_score As Integer = student_score.Max() Dim index As Integer = Array.IndexOf(student_score, highest_score) DataGridView1.Rows(index).Selected = True MsgBox("Student " & (student_name(index) & " has the maximum mark")) End Sub
Private Sub btnLowest_Click(sender As Object, e As EventArgs) Handles
btnLast.Click Dim lowest_score As Integer = student_score.Min() Dim index As Integer = Array.IndexOf(student_score, lowest_score) DataGridView1.Rows(index).Selected = True MsgBox("Student " & (student_name(index) & " has the minimum mark")) End Sub
Private Sub btnAverage_Click(sender As Object, e As EventArgs) Handles
btnAverage.Click Dim average_score As Double = total_score / count MsgBox("The average score is " & average_score.ToString) End Sub End Class