Faalamva
New member
- Joined
- Oct 22, 2015
- Messages
- 1
- Reaction score
- 0
- Points
- 0
Hi,
I'm using the following macro, very simple one, I just want to read the file toto.txt line by line :
However, my file toto.txt (available zipped here : sagel.free.fr/toto.zip), contains special characters (it's a dump of a database table).
It seems one of these special characters (displayed by vi as "^Z" at line 2, column 249 of my file) disturbs the EOF instruction, that exits at line 2 as soon as it reads this character.
As a consequence, my variable row_num displays value "2", whereas my file contains 6 lines...
I'd like my macro to go through all 6 lines of my file.
Where does this problem come from, and how can I fix my code ?
Thank you !
I'm using the following macro, very simple one, I just want to read the file toto.txt line by line :
Code:
Sub Go()
Dim File_Path As String
File_Path = "C:\toto.txt"
Open File_Path For Input As #1
row_num = 0
Do Until EOF(1)
Line Input #1, Line_FromFile
row_num = row_num + 1
Loop
Close #1
MsgBox row_num
End Sub
However, my file toto.txt (available zipped here : sagel.free.fr/toto.zip), contains special characters (it's a dump of a database table).
It seems one of these special characters (displayed by vi as "^Z" at line 2, column 249 of my file) disturbs the EOF instruction, that exits at line 2 as soon as it reads this character.
As a consequence, my variable row_num displays value "2", whereas my file contains 6 lines...
I'd like my macro to go through all 6 lines of my file.
Where does this problem come from, and how can I fix my code ?
Thank you !