VBA 7.0 in Excel,行输入似乎在行周围添加了额外的引号
VBA 7.0 in Excel, Line Input appears to add extra quotes around the line
我有一个包含以下行的文件:
one
two
three
当我从一个文件读取并写入另一个文件时,它们最终被引用。它们也在 watch window.
的变量中被引用
还有当我有一个文件时:
"one", "two", "three"
最后写成:
"""one"", ""two"", ""three"""
有人知道是什么原因造成的吗?我的文件扩展名为“.txt”。
谢谢你的时间。
下面的示例代码片段:
Public Sub ReadAndWrite()
Dim fhInput As Integer
Dim fhOutput As Integer
Dim strSingleLine As String
fhInput = FreeFile()
Open "<your input file here>" For Input As #fhInput
fhOutput = FreeFile()
Open "<your output file here>" For Output As #fhOutput
Do While Not EOF(fhInput)
Line Input #fhInput, strSingleLine
Write #fhOutput, strSingleLine
Loop
Close (fhInput)
Close (fhOutput)
End Sub
实际上是 Write
语句在字符串两边加上引号。如果你不想要,你应该使用 Print
。
我有一个包含以下行的文件:
one
two
three
当我从一个文件读取并写入另一个文件时,它们最终被引用。它们也在 watch window.
的变量中被引用还有当我有一个文件时:
"one", "two", "three"
最后写成:
"""one"", ""two"", ""three"""
有人知道是什么原因造成的吗?我的文件扩展名为“.txt”。
谢谢你的时间。
下面的示例代码片段:
Public Sub ReadAndWrite()
Dim fhInput As Integer
Dim fhOutput As Integer
Dim strSingleLine As String
fhInput = FreeFile()
Open "<your input file here>" For Input As #fhInput
fhOutput = FreeFile()
Open "<your output file here>" For Output As #fhOutput
Do While Not EOF(fhInput)
Line Input #fhInput, strSingleLine
Write #fhOutput, strSingleLine
Loop
Close (fhInput)
Close (fhOutput)
End Sub
实际上是 Write
语句在字符串两边加上引号。如果你不想要,你应该使用 Print
。