Link to home
Start Free TrialLog in
Avatar of silki
silki

asked on

Read from a TEXT file ??

HI

Can some please tell me the best way in vb to read froma text file

I have one.csv

silki,19,silki@mydomain.com
james,34,james@mydomain.com
SPJ,56,SPJ@mydomain.com

So i wish to read in each line do sumthing with the data then move next ?????

One question will this be reliable as my past ASP FSO experinec had been bad ????

SILKI

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Dim TextLine
Open "TESTFILE" For Input As #1   ' Open file.
Do While Not EOF(1)   ' Loop until end of file.
   Line Input #1, TextLine   ' Read line into variable.
   Debug.Print TextLine   ' Print to the Immediate window.
Loop
Close #1   ' Close file.
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of silki
silki

ASKER

Thanks

This is better as i need to deal with each one on its own

SILKI
Make sure you dimension the variables appropriately, so instead of all variants:
Dim Fld1, Fld2, Fld3

They could be:
Dim Fld1 As String, Fld2 As Integer, Fld3 As String

Thanks for the points,
Anthony