0

hello guys am working on a window application in vb.net Am trying to code an array that can add only 8 best subjects grades from the 10 subjects done by a student. the ten subject grades are dispayed as labels and also the TOTAL of best eight subject grades is dispayed as a label. Any one to help me. am new in pragramming

3
Contributors
3
Replies
16
Views
2 Years
Discussion Span
Last Post by Benard joseph
0

You will need to store the ten label values, may as well be in an array, sort it and either only access the first 8 or remove the last 2. Can you post up what code you've done then someone can edit it with advice on how to achieve what you need.

0
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' subject grades
        Label1.Text = 7
        Label2.Text = 1
        Label3.Text = 3
        Label4.Text = 8
        Label5.Text = 4
        Label6.Text = 9
        Label7.Text = 2
        Label8.Text = 5
        Label9.Text = 2
        Label10.Text = 6

        Dim gradeList As New ArrayList()
        gradeList.Add(Label1.Text)
        gradeList.Add(Label2.Text)
        gradeList.Add(Label3.Text)
        gradeList.Add(Label4.Text)
        gradeList.Add(Label5.Text)
        gradeList.Add(Label6.Text)
        gradeList.Add(Label7.Text)
        gradeList.Add(Label8.Text)
        gradeList.Add(Label9.Text)
        gradeList.Add(Label10.Text)


        'sort grades in an arraylist
        gradeList.Sort()

        ' Please guys help me and modify this code to sort and  SUM UP ONLY best eight done subject grades.
        ' I want label11.text to display the answer 
        'THANKS.

    End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.