Click here to Skip to main content
15,743,541 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my project I'm using a data grid to display the information that has been saved into the textile (Stock related information). I have used the code below and the error that is showing is "Index was outside the bounds of the array". Has anyone got any suggestions?
It would be appreciated.

What I have tried:

Dim fname As String = "C:\Users\Windows 7 User\Desktop\Stock.txt"
        Dim colsexpected As Integer = 8
        Dim thereader As New StreamReader(fname, Encoding.Default)
        Dim sline As String
            sline = thereader.ReadLine
            If sline Is Nothing Then Exit Do
            Dim words() As String = sline.Split(",")
            For ix As Integer = 0 To 7
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(ix).Value = words(ix)



Updated 7-Jan-18 7:08am
Kenneth Haugland 6-Jan-18 10:28am    
If its WPF I can help, but this feels like WinFroms? So is it?
faiqaa 6-Jan-18 11:38am    
Yes it's WinForms.
Richard MacCutchan 6-Jan-18 12:11pm    
What does "nothing is working for me" mean?
faiqaa 6-Jan-18 14:56pm    
I meant that I have looked online at other solutions but none of them has helped me in solving my issue.
Richard MacCutchan 6-Jan-18 15:25pm    
What issue?

1 solution

Share this answer

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