Ive bin looking for some code to export the contents of a DataGridView to CSV so I can view it in Excel.
I found this but ive got errors;
Dim sr As StreamWriter = File.CreateText(strExportFileName)
Dim strDelimiter As String = strDelimiterType
Dim intColumnCount As Integer = DataGridView.Columns.Count - 1
Dim strRowData As String = ""
If blnWriteColumnHeaderNames Then
For intX As Integer = 0 To intColumnCount
strRowData += Replace(DataGridView.Columns(intX).Name, strDelimiter, "") & _
IIf(intX < intColumnCount, strDelimiter, "")
Next intX
sr.WriteLine(strRowData)
End If
For intX As Integer = 0 To DataGridView.Rows.Count - 1
strRowData = ""
For intRowData As Integer = 0 To intColumnCount
strRowData += Replace(DataGridView.Rows(intX).Cells(intRowData).Value, strDelimiter, "") & _
IIf(intRowData < intColumnCount, strDelimiter, "")
Next intRowData
sr.WriteLine(strRowData)
Next intX
sr.Close()
MsgBox("saved!")