ranhell
asked on
Visual Basic 6 read TXT file and store it in different fields again
have the following Test.txt file content
field1 field2 field3
1 1 0035300608E000233004
1 2 0035160508E000012950
2 3 0035210508E000017574
Separated by a blank space each and CR at the end
I need to read this file from an specific folder "Say C:\TEST\Test.txt" or Optionally browse for the TXT file and store each field in Access 2003 using DAO Recordset
Any written code or sample code is very much appreaciated
field1 field2 field3
1 1 0035300608E000233004
1 2 0035160508E000012950
2 3 0035210508E000017574
Separated by a blank space each and CR at the end
I need to read this file from an specific folder "Say C:\TEST\Test.txt" or Optionally browse for the TXT file and store each field in Access 2003 using DAO Recordset
Any written code or sample code is very much appreaciated
ASKER
What is the difference between this code below and the one you provided.
dim fso as object 'scripting.filesystemobjec t
set fso = createobject("scripting.fi lesystemob ject") ' = new scripting.filesystemobject
dim fReader as object 'scripting.TextStream
set fReader = fso.OpenTextStream("C:\TES T\Test.txt ") 'optional second argument is ForReading...
dim strLine as string
dim arrfields() as string
while not fReader.AtEndOfStream
strLine = fReader.ReadLine
arrFields = split(strLine, " ")
'here, you can insert the data into the records... I do assume you know how to do that?
wend
freader.Close
set freader = nothing
set fso = nothing
dim fso as object 'scripting.filesystemobjec
set fso = createobject("scripting.fi
dim fReader as object 'scripting.TextStream
set fReader = fso.OpenTextStream("C:\TES
dim strLine as string
dim arrfields() as string
while not fReader.AtEndOfStream
strLine = fReader.ReadLine
arrFields = split(strLine, " ")
'here, you can insert the data into the records... I do assume you know how to do that?
wend
freader.Close
set freader = nothing
set fso = nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
2/ do you need to use a recordset as i find SQL easier.
Open in new window