我想问如何将datagridview从vb6.0导出到.txt格式?我编写此代码以查看表的内容到datagridview
Call Buka
koneksi.CursorLocation = adUseClient
rsDTS.Open "select * from TBL_DTSHEET where KDKRY = '" & txtKdKry.Text & "' and (TGLWORK between '" & Format(dtAwal.Value, "mm/dd/yyyy") & "' and '" & Format(dtAkhir.Value, "mm/dd/yyyy") & "')", koneksi
With rsDTS
If Not (.BOF And .EOF) Then
mvBookmark = .Bookmark
End If
End With
Set DataGrid1.DataSource = rsDTS.DataSource
现在,我想知道如何将此datagridview导出到使用格式.txt的文件中?有人可以帮忙吗?谢谢
我想我可以通过添加一些代码来解决自己的问题
Open "D:textfile.txt" For Output As #1
Do While rsDTS.EOF = False
Print #1, rsDTS.Fields("KDDTS").Value & ", " & rsDTS.Fields("KDHDTS").Value & ", " & rsDTS.Fields("TGLWORK").Value
rsDTS.MoveNext
Loop
Close #1
希望这可以帮助他人