i have this error when i display my program ?

' Created by SharpDevelop.
' User: s11088659
' Date: 5/28/2014
' Time: 11:26 AM
' To change this template use Tools | Options | Coding | Edit Standard Headers.
Public Partial Class MainForm
    Public Sub New()
        ' The Me.InitializeComponent call is required for Windows Forms designer support.

        ' TODO : Add constructor code after InitializeComponents
    End Sub

    private Sub DisplaybuttonClick(byval sender As Object,byval e As system.EventArgs)
        'Declare variable of array name and grade of student

        'Dim strNames() As String = {“Hova”, “Nemo”, “Zoc”, “Lucas”,“Phuket”, “Cindy”, “Marlin”, “Darla”, “Nigel”, “Cindrella”}
         Dim dblMarks() As Double = {32.5,88,90.5,67.5,65,77.5,85,78.5,89.5,90}
         Dim int As Integer
         Dim intotal As Integer
         Dim avg As Decimal

         For int = 0 To 11
            intotal = intotal + dblMarks(int)
         Next int

         avg = convert.ToDecimal(intotal/dblMarks.Length)
         displaylabel.text = " Average: " & avg.tostring("N1")

    End Sub

End Class

Index was outside the bounds of the array.what should i do to solve the error?

You have only added 10 elements to the array dblMarks but you are stepping up to 11 in your loop. No position 11 exists in the array.

i change it back to 10 but does present the same error..

the error is in line 29

ops...sorry i just fix it thanx

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.