Bob Barnes said:
Dirk - Here it is...Notice how the first string of 050234 is WITHOUT
double quotes (that's how the software writes it).
ALL commas currently in text will be replace w/ ...
Thank you - Bob
050234,"050234",2006-08-24 00:00:00,2006-08-24 00:00:00,"154","Is the
center maintaining copies of all hotwork permits issued for the site
for a period of one year?","If a hotwork permit is issued for a
facility, that facility is required to maintain both the pink and
yellow copies of the permit in their Compliance Manual for a period
of one (1) year.","CTOA","Other",2006-08-29 00:00:00,2006-08-30
00:00:00,"hot work permit found",""
Here's a simple example of parsing into fields using the comma as a
delimiter. It reads and parses only a single line from the file --
there's no loop logic to read multiple lines.
'----- start of code -----
Dim sPath As String
Dim iFile As Integer
Dim sLine As String
Dim aFields() As String
Dim iX As Integer
sPath = "C:\Temp\BarnesTest.txt" ' substitute your path
iFile = FreeFile
Open sPath For Input As #iFile
' Read a line into a string variable
Line Input #iFile, sLine
' Split the line based on the comma delimiter
aFields = Split(sLine, ",")
' Report the results.
Debug.Print "The line has "; UBound(aFields) + 1; " fields."
For iX = 0 To UBound(aFields)
Debug.Print "Field " & iX & ":", aFields(iX)
Next iX
Close iFile
'----- end of code -----
Now, I see a problem using this simple approach with the sample line you
posted. One of the text strings that make up the line includes a comma.
This simplistic parsing won't understand that a comma that is within
quotes must be ignored, not used as a delimiter. I'm not sure whether
your statement that
ALL commas currently in text will be replace w/ ...
means that this won't be a problem in practical application.