Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading from a txt file

Status
Not open for further replies.

newbie1983

Programmer
Sep 9, 2003
52
GB
i am a novice at vb/vba , id like to know how to read from a text file line by line? ive completed some code:

Dim sPath As String
Dim sName As String
Dim Reading As String
Dim ofso1 As New FileSystemObject

Set Read = ofso1.OpenTextFile(sPath & xlCell.Value & sName)
Reading = Read.readline ?

End Sub
 
I think the easiest way is still to go with old-style basic commands, for example:

i=0
open "MyFile.txt" for input as #1
do while not eof(1)
i=i+1
line input#1, s
cells(i,1)=s
loop
close#1


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top