View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Foss[_2_] Foss[_2_] is offline
external usenet poster
 
Posts: 7
Default Reading a text file line by line

Hi there,

I'm trying to loop through a text file, processing each line of the file
depending on the values it contains.

Here's what I've got so far, all those bits don't need to be per line, they
apply to the whole file.

So my question is, how can I loop on the line number of the file?

Sub fdsa()
Dim FileNumber As Integer, FileLength As Integer, FilePath As String,
FullString As String
FilePath = "C:\The Export 2.txt"
FileNumber = FreeFile
Open FilePath For Input As FileNumber
FileLength = LOF(FileNumber)

FullString = Input(FileLength, FileNumber)
MsgBox FullString, vbInformation + vbOKOnly

FullString = Replace(FullString, Chr(9), "")
MsgBox FullString, vbInformation + vbOKOnly

FullString = Replace(FullString, ".00", "")
MsgBox FullString, vbInformation + vbOKOnly

Close #FileNumber
End Sub


Cheers,
Foss