请教读写mdb文件改成读写txt文件
先生们晚上好,我能读写mdb文件的代码,现在想修改成读写txt文件的代码,修改了好多次,总是没成功,请教您们如何修改,谢谢原读写mdb文件代码如下,想修改成读写txt文件
Dim a(1 To 23, 1 To 13) As Currency
Private Sub Form_Click()
'-----------------------读"原方阵.mdb"文件,现在想改成读取“原方阵.txt”文件
Dim Bcn1 As New ADODB.Connection
Dim Brs1 As New ADODB.Recordset
Bcn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\原方阵.mdb"
Brs1.Open "b1", Bcn1, 1, 3
For i = 1 To 23
For j = 1 To 13
a(i, j) = Brs1.Fields("列" & j).Value
Next j
Brs1.MoveNext
Next i
'
'------------------------写入"搜索结果表.mdb"文件,现在想改成写入到“搜索结果表.txt”
Dim Conn As New ADODB.Connection
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\搜索结果表.mdb"
Conn.Execute "delete * from B1"
Conn.Close
Dim FF1cn1 As New ADODB.Connection
Dim FF1rs1 As New ADODB.Recordset
FF1cn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\搜索结果表.mdb"
FF1rs1.Open "b1", FF1cn1, 1, 3
FF1rs1.AddNew
FF1rs1.AddNew
Me.WindowState = 0
'=========================================写入
For i = 1 To 23
For j = 1 To 13
FF1rs1("列" & j) = a(i, j)
Next j
FF1rs1.Update
FF1rs1.AddNew
Next i
'----------------------写入文件结束
End Sub
vb读写txt文件.rar
(25.86 KB)