如何将vb datagrid中显示的数据导入文本

来源:百度知道 编辑:UC知道 时间:2024/05/29 23:57:28
我连接的数据库是SQL SERVER,做一些操作后datagrid上会显示筛选好的数据。
现在我想执行command命令后,把这些数据存入到文本文件中,请问该怎么实现啊谢谢了,就是想要写入文本文件的这个语句,拜托了

文件通用读、写、追加函数

Sub Appdoc(ByVal docpath As String, ByVal txt As String)'追加记录函数
Open docpath For Append As #1
Print #1, txt
Close #1
End Sub

Public Function openfile(ByVal filepath As String) As String'读入文件函数
Dim s As String
Open filepath For Input As #1
While Not EOF(1)
Line Input #1, sline
s = s & sline & vbCrLf
Wend
Close #1
openfile = s
End Function

Public Function savefile(ByVal filepath As String, ByVal txt As String)'保存文件函数
Open filepath For Output As #1
Print #1, txt
Close #1
End Function