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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through a comma delimitated file.... 1

Status
Not open for further replies.

Ross1811

MIS
Oct 1, 2004
122
0
0
US
Hi Everyone,

Is it possible to loop through a comma delimitated file with vbscript? If so how?


Thanks,
Ross
 
[1] To loop through a text file (which comma delimited file is), it is this.
[tt]
set fso=createobject("scripting.filesystemobject")
set ots=fso.opentextfile("d:\test\abc.csv",1,true,-2)
do while not ots.atendofstream
s=ots.readline
'do thing with info contained in the line
loop
ots.close
set ots=nothing
set fso=nothing
[/tt]
[2] To read data in the comma delimited string.
[tt]
s="abc,def,,pqr"
a=split(s)
for i=0 to ubound(a)
'do thing with data a(i)
next
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top