D
Daniel
Hello,
I have the following code to read through a text file
Dim FileNumber As Integer
Dim sFile As String
FileNumber = FreeFile
Open strFile For Input As #FileNumber 'open the file
Dim strLine As String
Do Until EOF(FileNumber) 'loop through each line in the
file
Line Input #FileNumber, strLine 'store the line as a variable
ReadTxt = ReadTxt & strLine
Loop
Close #FileNumber 'close the file
Then I do the following
arrstrTxt = Split(ReadTxt, vbKeyReturn)
For i = LBound(arrstrTxt) To UBound(arrstrTxt)
Debug.Print "Line: " & i & vbCrLf & arrstrTxt(i)
Next i
The problem being that it only returns 21 lines when in fact, when
viewed/printed it actually has 157. I have tried variation in the split
function (chr(10), chr(13), vbcrlf,...) to no avail.
I analyzed the file a realized that each line has 132 characters. Is there
a way to read through a file 132 characters at a time? or any mistakes with
my prior code that would explain my problem?
Thank you for your help,
Daniel P
I have the following code to read through a text file
Dim FileNumber As Integer
Dim sFile As String
FileNumber = FreeFile
Open strFile For Input As #FileNumber 'open the file
Dim strLine As String
Do Until EOF(FileNumber) 'loop through each line in the
file
Line Input #FileNumber, strLine 'store the line as a variable
ReadTxt = ReadTxt & strLine
Loop
Close #FileNumber 'close the file
Then I do the following
arrstrTxt = Split(ReadTxt, vbKeyReturn)
For i = LBound(arrstrTxt) To UBound(arrstrTxt)
Debug.Print "Line: " & i & vbCrLf & arrstrTxt(i)
Next i
The problem being that it only returns 21 lines when in fact, when
viewed/printed it actually has 157. I have tried variation in the split
function (chr(10), chr(13), vbcrlf,...) to no avail.
I analyzed the file a realized that each line has 132 characters. Is there
a way to read through a file 132 characters at a time? or any mistakes with
my prior code that would explain my problem?
Thank you for your help,
Daniel P