I'm currently creating a database that needs to read through the lines of a text file one at a time and alter certain characters. I do not have a problem with the altering of the characters, however there is a problem with grabbing the entire lines from the file. Below is some example code which I hope you can understand:
In the above example, the text file contains many records which have fields that are not comma seperated. In other words I am setting up the field splits using import specs. After opening each line I make the relevant changes and then add it to a different output file. The problem is that most of the lines are opened correctly, however if there is a comma in any of the fields of the line, it counts this as a line break and splits the line into sections. The below example line is made up from 4 fields - ID, Name, Description and Ref No:
1BobManager approved changes, contact customer375349
When the code gets to this line it would first take "1BobManager approved changes" and then the next time around it would take "contact customer375349". What I want is for the whole line to be taken. Does anyone know why this is happening and how to get around it? Most of the lines do not contain any commas and so are detected correctly.
Please help!
Code:
Dim intTextFile As Integer
Dim strPath As String
Dim strFileName As String
Dim strInputLine As String
strPath = "C:\"
strFileName = "test"
'Open the text file
intTextFile = FreeFile
Open strPath & strFileName & ".txt" For Input As #intTextFile
'Go through the input file line by line...
Do While Not EOF(intTextFile)
'Open current line
Input #intTextFile, strInputLine
In the above example, the text file contains many records which have fields that are not comma seperated. In other words I am setting up the field splits using import specs. After opening each line I make the relevant changes and then add it to a different output file. The problem is that most of the lines are opened correctly, however if there is a comma in any of the fields of the line, it counts this as a line break and splits the line into sections. The below example line is made up from 4 fields - ID, Name, Description and Ref No:
1BobManager approved changes, contact customer375349
When the code gets to this line it would first take "1BobManager approved changes" and then the next time around it would take "contact customer375349". What I want is for the whole line to be taken. Does anyone know why this is happening and how to get around it? Most of the lines do not contain any commas and so are detected correctly.
Please help!