'下面是个例子,假设你的Test.txt文件在C盘根目录下
'注意,工程要引用ADO哟
程序代码:
Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Conn.Open "DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=C:\;", "", "" '注意里面每一个空格哦,后面两个空值的参数是userid,password
Rs.Open "select * from [Test.txt]", Conn, adOpenStatic, adLockReadOnly, adCmdText
MsgBox Rs.RecordCount
Rs.Close
Conn.Close
End Sub
===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================