我想从文本文件的第二行读取并将其数据写入文件CSV
。
实现这个的最佳方法是什么?
Open InputFile For Input As #1
Open OutputFile For Output As #2
Do Until EOF(1)
Line Input #1, strData
'Read data from second line of text file and Write into CSV file
Print #2, strData
Loop
Close #1
Close #2
答案1
只需读第一行并将其丢弃:
Sub Luxation()
Dim InputFile As String, OutputFile As String, strData As String
InputFile = "C:\TestFolder\File1.txt"
OutputFile = "C:\TestFolder\xxxx.txt"
Open InputFile For Input As #1
Open OutputFile For Output As #2
Line Input #1, strData
Do Until EOF(1)
Line Input #1, strData
Print #2, strData
Loop
Close #1
Close #2
End Sub