VBA 读取文件 逗号没了
Dim fname As String
dim str As String
fname = "d:\123\123.txt"
Open fname For Input As #1
Do
Input #1,str
Loop While EOF(1)=False
Close #1
文件内容为
diff:aaaaavvvvsss
3333,4455C6666,8888
...
读取以后str的内容变为
diff:aaaaavvvvsss
33334455C66668888
...
这是什么原因? 我用的是EXCEL2007
[解决办法]
Input 改成line input试试
[解决办法]
str是个函数的名字,不要定义为变量的名字,属于VB的保留字
Dim fname As Stringdim Mystr As Stringfname = "d:\123\123.txt"Open fname For Input As #1Do While EOF(1)=FalseLineInput #1,Mystr 'str里面放着每行的内容'在这里处理Mystr LoopClose #1