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

Recommended Answers

All 3 Replies

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.

    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

Hey guys, am very interesting in Pragram,were should i start!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.