hey im new here and newish to vb.net which im studying at uni. Ive created a code which calculates students grade points and displays the No of cat points they have got alltogether. An example of this would be if they got 13 -15 then they get a first for that module and they would get 1 displayed in a textbox , if they get another then they get two....and so on....
anyway geting back to the point, i have to display the highest, lowest and average grade point and not sure which is the easyest way to do this based on the code ive pasted below. I was thinking an array but i dont understand the feature, although knowing what it can do. i also have a secound form which i will not paste on here as it only display the results of the variables ect "firstclass" in a text box. Anyway any ideas what approach i should take to carryout the calculations? p.s havn't named the controlls yet as im lazy,lol yet there aint tat many.
hope u can help
dave
anyway geting back to the point, i have to display the highest, lowest and average grade point and not sure which is the easyest way to do this based on the code ive pasted below. I was thinking an array but i dont understand the feature, although knowing what it can do. i also have a secound form which i will not paste on here as it only display the results of the variables ect "firstclass" in a text box. Anyway any ideas what approach i should take to carryout the calculations? p.s havn't named the controlls yet as im lazy,lol yet there aint tat many.
VB.NET:
Public Class Form1
Public firstclass As Double
Public Uppersecound As Double
Public Lowersecound As Double
Public Thirdclass As Double
Public fail As Double
Public Totalresults As Double
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim results As String
results = TextBox2.Text
results = check(results)
Totalresults = Totalresults + results
If RadioButton1.Checked Then
calculate15(results)
End If
If RadioButton2.Checked Then
calculate30(results)
Else
MsgBox("Please select a total score your grade is marked out of from the point grade option box e.g. 15 or 30")
End If
End Sub
Private Function check(ByVal checkresults) As String
If IsNumeric(checkresults) = False Then
MsgBox("Please insert a numeric value e.g. 1 not ONE")
checkresults = -1
check = CDbl(checkresults)
Else
check = CDbl(checkresults)
End If
End Function
Private Sub calculate15(ByVal results)
If results > 12 And results < 16 Then
firstclass = firstclass + 1
End If
If results > 9 And results < 13 Then
Uppersecound = Uppersecound + 1
End If
If results > 6 And results < 10 Then
Lowersecound = Lowersecound + 1
End If
If results > 3 And results < 7 Then
Thirdclass = Thirdclass + 1
End If
If results >= 0 And results < 4 Then
fail = fail + 1
Else
MsgBox("The number you inserted is an invalid number! Note: if you wish to caculate your score out of 30 grade points, please remember to select 30 from the selection box, otherwise enter an invalid number from 0-15")
End If
If results = -1 Then
TextBox2.Text = ""
TextBox2.Focus()
End If
End Sub
Private Sub calculate30(ByVal results)
If results > 25 And results < 31 Then
firstclass = firstclass + 1
End If
If results > 20 And results < 26 Then
Uppersecound = Uppersecound + 1
End If
If results > 16 And results < 21 Then
Lowersecound = Lowersecound + 1
End If
If results > 13 And results < 17 Then
Thirdclass = Thirdclass + 1
End If
If results >= 0 And results < 14 Then
fail = fail + 1
End If
If results = -1 Then
TextBox2.Text = ""
TextBox2.Focus()
Else
MsgBox("The number you inserted is an invalid number! Note: if you wish to caculate your score out of 30 grade points, please remember to select 30 from the selection box, otherwise enter an invalid number from 0-15")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
Me.Close()
End Sub
End Class
hope u can help
dave
Last edited by a moderator: