Hello
i have issue with my code i make mistake and can't export the information from DataGridView column rows to text file.
Form_Load code:
Using objReader As New StreamReader(\Line.dat")
Do While objReader.Peek() <> -1
Dim line As String = objReader.ReadLine()
Dim splitLine() As String = line.Split(";")
Dim teamName As String = Convert.ToString(splitLine(0))
Dim gamesWon As String = splitLine(1).ToString()
Dim gamesLost As String = splitLine(2).ToString()
Guna2DataGridView1.Rows.Add(teamName, gamesWon, gamesLost)
Loop
End Using
Line.dat file:
Line1;IM08+IU08;20,14,A
Button Save Changes to File
Using writer As New StreamWriter(\Line.dat")
For i As Integer = 0 To Guna2DataGridView1.Rows.Count - 2 Step +1
For j As Integer = 0 To Guna2DataGridView1.Columns.Count - 1 Step +1
If j = Guna2DataGridView1.Columns.Count - 1 Then
writer.Write(Guna2DataGridView1.Rows(i).Cells(j).Value?.ToString())
Else
writer.Write(Guna2DataGridView1.Rows(i).Cells(j).Value?.ToString() & ";")
End If
Next j
writer.WriteLine("")
Next i
'MessageBox.Show("CGTypes were configurated successfully!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Using
and result of the export is that its missing the default value from the column3 rows, what it saves is:
Line1;IM08+IU08;20,14,A
Line2;IU22+IT23;
It does not save the 20,14,A in the end.