I am new to the forum and my first post happens to be a issue that I am having with a GPA calculator. I am tasked to create a program that the user to enter a gender (F or M) and GPA for any number of students. The application should calculate the average GPA of All students (F and M) and the GPA of all Females and all Males. The UI has a list box that contains GPAs 1.0 to 4.0 with increments of .1. Also the way to enter Female or Male by using radio boxes.
My problem is that I can not display the averages in the labels that are contained in a groupbox. I have gone through my text box and I find examples that work. Sadly, they do not seem to work for me. Here is my code:
Option Explicit On Option Strict On Option Infer Off Public Class frmMain Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click ' to close the program Me.Close() End Sub Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' fill the list box with GPA values For dblGPA As Double = 1 To 4.1 Step 0.1 lstGPA.Items.Add(dblGPA.ToString) Next dblGPA End Sub Private Sub btnCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalc.Click ' Calculates the avg. of 20 students Dim dblGPA As Double Dim lblFemale As Double Dim lblMale As Double Dim lblAll As Double Double.TryParse(lstGPA.SelectedItem.ToString, dblGPA) If radFemale.Checked = True Then lblFemale = dblGPA + 10 lblFemale = lblFemale / 10 Else If radMale.Checked = True Then lblMale = dblGPA + 10 lblMale = lblMale / 10 End If End If End Sub End Class
The btnCalc_Click isn't complete. I am just trying to get something to show in the labels.