Connecting Tech Pros Worldwide Forums | Help | Site Map

help me plz. i dont have the help files so i cant look this up

Newbie
 
Join Date: Oct 2009
Posts: 2
#1: 4 Weeks Ago
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



Newbie
 
Join Date: Oct 2009
Posts: 2
#2: 4 Weeks Ago

re: help me plz. i dont have the help files so i cant look this up


you know what. i figured that out. but now the line
Do While decGPA <> String.Empty
is telling me the same thing. what am i doing wrong?
Newbie
 
Join Date: Oct 2009
Posts: 28
#3: 4 Weeks Ago

re: help me plz. i dont have the help files so i cant look this up


Well to begin with you are using VB.NET and this forum is for "classic" VB version 4/5/6. So perhaps posting in the right forum might help you out more.



Good Luck
Reply

Tags
casting from a number, gpa, visual basic help


Similar Visual Basic 4 / 5 / 6 bytes