csv文件问题
数据库是.csv,怎样将窗口的Text1.Text~Text4.Text 输出到1.csv时,每一条记录一行,用excel打开时数据分别在A1,B1,C1,D1。。
Private Sub Command1_Click() Dim Conn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim i As Integer Dim sql As String STRNAME = App.Path & "\book1.csv" strSheetName = "book1" Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & STRNAME & ";Extended Properties='Excel 8.0;HDR=Yes'" sql = "select * from [" & strSheetName & "$]" rs.Open sql, Conn, 1, 3 rs.AddNew rs(0) = Text1 rs(1) = Text2 rs.Update rs.Close Conn.Close End Sub
Private Sub Command1_Click() Dim FileNum As Long FileNum = FreeFile Open App.Path & "\book1.csv" For Append As #FileNum Print #FileNum, Text1 & " ," & Text2 & " ," & Text3 & " ," & Text4 & " ," & Text5 Close #FileNum End Sub