0% found this document useful (0 votes)
25 views3 pages

Grade Tracker Project in VB

Uploaded by

austinjiang15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Grade Tracker Project in VB

Uploaded by

austinjiang15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Grade Tracker project in VB.NET, using Visual Studio.

Steps to Design the GUI

1. Create a New Project:


o Open Visual Studio.
o Click File > New > Project.
o Select Windows Forms App (.NET Framework), name it (e.g.,
GradeTracker), and click Create.
2. Setup the Form:
o Open the default form (Form1).
o Resize the form as needed by dragging its edges.
3. Add Controls to the Form: You can add controls by dragging them from the
Toolbox onto the form.

Controls to Add:

1. Input Section:
o Label: Set Text to "Enter Grade:".
o TextBox: Name it txtGradeInput.
o Button: Name it btnAddGrade and set Text to "Add Grade".
2. Display Section:
o ListBox: Name it lstGrades to display the list of grades.
3. Statistics Section:
o Buttons:
 Name: btnCalculateAverage, Text: "Calculate Average".
 Name: btnFindHighest, Text: "Find Highest".
 Name: btnFindLowest, Text: "Find Lowest".
o Labels:
 Name: lblAverage, Text: "Average: ".
 Name: lblHighest, Text: "Highest: ".
 Name: lblLowest, Text: "Lowest: ".
4. Optional (Clear Button):
o Button: Name it btnClear, Text: "Clear Grades".

Arranging the Controls:

 Top Section (Input): Place the "Enter Grade" label, txtGradeInput, and
btnAddGrade horizontally at the top of the form.
 Left Section (Display): Add the lstGrades ListBox to the left-middle part of the
form.
 Right Section (Statistics): Arrange the statistics buttons (btnCalculateAverage,
btnFindHighest, btnFindLowest) vertically on the right side.
 Bottom Section: Place the statistics labels (lblAverage, lblHighest, lblLowest)
and btnClear at the bottom.

Setting Properties:

 Select each control and set its properties using the Properties Window:
o TextBox (txtGradeInput):
 Set Multiline to False.
o Buttons:
 Set the Font to a readable size, e.g., 10 or 12.
 Ensure the Name property corresponds to the code provided.
o Labels:
 Set the AutoSize property to True.
o ListBox (lstGrades):
 Set ScrollAlwaysVisible to True.

Final GUI Layout (Example):

Below is how the form might look:

markdown
Copy code
------------------------------------------
| Enter Grade: [__________] [Add Grade] |
| |
| Grades List: |
| [Grade1 ] |
| [Grade2 ] |
| [Grade3 ] |
| |
| [Calculate Average] [Find Highest] |
| [Find Lowest ] |
| Average: ______ |
| Highest: ______ |
| Lowest: ______ |
| [Clear Grades] |
------------------------------------------

Add Event Handlers:

1. Double-click each button to create the Click event handlers.


2. Copy and paste the corresponding code into the event handlers, such as:
o btnAddGrade_Click
o btnCalculateAverage_Click
o btnFindHighest_Click
o btnFindLowest_Click
o btnClear_Click
Example Completed Code for Form Events:
Private Sub btnAddGrade_Click(sender As Object, e As EventArgs) Handles
btnAddGrade.Click
Dim grade As Integer
If Integer.TryParse(txtGradeInput.Text, grade) Then
grades.Add(grade)
lstGrades.Items.Add(grade)
txtGradeInput.Clear()
Else
MessageBox.Show("Please enter a valid grade.", "Input Error")
End If
End Sub

Private Sub btnCalculateAverage_Click(sender As Object, e As EventArgs)


Handles btnCalculateAverage.Click
If grades.Count > 0 Then
Dim average As Double = grades.Average()
lblAverage.Text = "Average: " & average.ToString("F2")
Else
MessageBox.Show("No grades to calculate.", "Error")
End If
End Sub

Private Sub btnFindHighest_Click(sender As Object, e As EventArgs) Handles


btnFindHighest.Click
If grades.Count > 0 Then
lblHighest.Text = "Highest: " & grades.Max().ToString()
Else
MessageBox.Show("No grades to analyze.", "Error")
End If
End Sub

Private Sub btnFindLowest_Click(sender As Object, e As EventArgs) Handles


btnFindLowest.Click
If grades.Count > 0 Then
lblLowest.Text = "Lowest: " & grades.Min().ToString()
Else
MessageBox.Show("No grades to analyze.", "Error")
End If
End Sub

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles


btnClear.Click
grades.Clear()
lstGrades.Items.Clear()
lblAverage.Text = "Average: "
lblHighest.Text = "Highest: "
lblLowest.Text = "Lowest: "
End Sub

You might also like