Hi everyone I'm fairly inexperienced with VB but have been trying to get "save" functionality out of a program I'm trying to write.

Basically I have a Datagridview and I want to write each line from the grid into a .txt file. So what I've been trying to do is use Datagridview.Items and then variables as column / row indexes to move cell by cell left to right , writing each cells data to an array which also increments along the way. Then using WriteLine to write the array to the text file, zero'ing all the counters then starting all over again for the next row.... make sense?

Now .. I keep getting an error sayin im using the "gridData(DataColumn)" array before I've assigned a value to it... thing is this error occurs on the code line where I am assigning a value to it?!

Here's the code:

Code:
        Dim gridData()

        Dim DataColumn, DataRow, i As Integer

        DataRow = 0
        i = 0

        FileOpen(1, FileName, OpenMode.Output)


        Do Until DataRow = DataGridView1.RowCount()

            For DataColumn = 0 To DataGridView1.ColumnCount

                gridData(DataColumn) = CStr(DataGridView1.Item(DataColumn, DataRow).Value) '<--- error happens here?'
                DataColumn = DataColumn + 1

            Next

            WriteLine(1, gridData)
            DataRow = DataRow + 1

        Loop

Hoping someone can help me sort this out? I am well aware that life would be easier if I bound the grid to a database but to be honest the fact that this is harder to do as a text file makes me more interested and if I was to share the finished product with friend ect I wouldn't expect them all to have access ect installed...

I look forward to responses !

Many Thanks in Advance!

(Using VB 2008 Express)