|
This is the code i was working on. i know it is clunky but im new to this. at the spot that sais RIGHT HERE i am getting this error statement when i try to run it:
when casting from a number the value must be a number less than infinity
and
make sure the source type is convertible to the destination type
this is just a gpa calculator, with male and female radials and output for avg male femal and all gpa's. list box like this:
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'fill listbox with values
For decGPA As Decimal = 1.0 To 4 Step 0.1
lstGPA.Items.Add(decGPA.ToString)
Next
lstGPA.SelectedItem = "1"
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim decGPA As Decimal
Dim decMale As Decimal
Dim decFemale As Decimal
Dim decAll As Decimal
Dim intFemaleCounter As Integer
Dim intMaleCounter As Integer
Dim intAllCounter As Integer
Dim decAccumMale As Decimal
Dim decAccumFemale As Decimal
Dim decAccumAll As Decimal
decGPA = Convert.ToDecimal(lstGPA) <-- RIGHT HERE
If radFemale.Checked Then
Do While decGPA <> String.Empty
intAllCounter = intAllCounter + 1
intFemaleCounter = intFemaleCounter + 1
decAccumAll = decAccumAll + decGPA
decAccumFemale = decAccumFemale + decGPA
decAll = decAccumAll / Convert.ToDecimal(intAllCounter)
lblALLOut.Text = Convert.ToString(decAll)
decFemale = decAccumFemale / Convert.ToDecimal(intFemaleCounter)
lblFemaleOut.Text = Convert.ToString(decFemale)
Loop
End If
End Sub
End Class
|