Click here to Skip to main content
15,914,795 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB.NET
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        gradeList.Items.Add(textgrade.Text)
        textgrade.Clear()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim total As Double
        Dim avg As Double
        Dim grade As Double
        Dim gradecount As Integer
        For gradecount = 0 To gradeList.Items.Count - 1
            grade = gradeList.Items.(gradecount) ' <-- ERROR here! --------
            total += grade
        Next
        avg = total / gradeList.Items.Count
        Label3.Text = "Media totală este " & total & vbCrLf & "Scorul total este " & avg
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Label3.Text = String.Empty
    End Sub
End Class


What I have tried:

I don't know what to do
grade = gradeList.Items.(gradecount)
Posted
Updated 2-Mar-18 6:12am
v3
Comments
Richard Deeming 2-Mar-18 11:53am    
Why have you tagged this question as "C#", when it has nothing at all to do with C#?

Items.( => Items(
 
Share this answer
 
I think this is a mistake:

VB
' grade = gradeList.Items.(gradecount)

grade = gradeList.Items(gradecount)
 
Share this answer
 
Comments
Alex Jianu 2-Mar-18 11:30am    
It worked, thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900