Private Sub Command1_Click() Dim fPath As String, strTemp As String, fLen As Long, a() As String fPath = "c:\test.txt" fLen = FileLen(fPath) strTemp = Space(fLen) Open fPath For Binary As #1 Get 1, 1, strTemp Close 1
a = Split(strTemp, ",") End Sub
楼主是不是写错了,怎么都是等于1 都等于1就好办了 Private Sub Command1_Click() Dim fPath As String, strTemp As String * 1 , fLen As Long, a() As String fPath = "c:\test.txt" Open fPath For Binary As #1 Get 1, 1, strTemp '只读第一个字符值为1 Close 1 for i = 0 to 3 a(i)= strTemp next End Sub
Dim fs, f Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.OpenTextFile(SourceFile) Dim tmpstring As String Dim tempData
Do While Not f.AtEndOfStream tmpstring = f.ReadLine tempData = Split(tmpstring, ",", -1, vbTextCompare) Loop f.Close Set fs = Nothing
因为你的文件里存在双引号,在代码中加一句就好了(去掉双引号) strTemp = Replace(strTemp, Chr(34), "")Private Sub Command1_Click() Dim fPath As String, strTemp As String, fLen As Long, a() As String fPath = "c:\test.txt" fLen = FileLen(fPath) strTemp = Space(fLen) Open fPath For Binary As #1 Get 1, 1, strTemp Close 1 strTemp = Replace(strTemp, Chr(34), "") a = Split(strTemp, ",") End Sub
Dim fPath As String, strTemp As String, fLen As Long, a() As String
fPath = "c:\test.txt"
fLen = FileLen(fPath) strTemp = Space(fLen)
Open fPath For Binary As #1
Get 1, 1, strTemp
Close 1
a = Split(strTemp, ",")
End Sub
Private Sub Command1_Click()
Dim fPath As String, strTemp As String * 1 , fLen As Long, a() As String
fPath = "c:\test.txt"
Open fPath For Binary As #1
Get 1, 1, strTemp '只读第一个字符值为1
Close 1
for i = 0 to 3
a(i)= strTemp
next
End Sub
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(SourceFile)
Dim tmpstring As String
Dim tempData
Do While Not f.AtEndOfStream
tmpstring = f.ReadLine
tempData = Split(tmpstring, ",", -1, vbTextCompare)
Loop
f.Close
Set fs = Nothing
strTemp = Replace(strTemp, Chr(34), "")Private Sub Command1_Click()
Dim fPath As String, strTemp As String, fLen As Long, a() As String
fPath = "c:\test.txt"
fLen = FileLen(fPath) strTemp = Space(fLen)
Open fPath For Binary As #1
Get 1, 1, strTemp
Close 1 strTemp = Replace(strTemp, Chr(34), "")
a = Split(strTemp, ",")
End Sub