Reading ASCII Text File

areichhart

New member
Local time
Today, 18:52
Joined
Jul 16, 2000
Messages
5
Hi out there,
can anybody tell me how to assign the content of a pure ASCII text file to a String using VB? I tried "Open" and some others but I never made it work. Could anybody please just give me the few lines of code I need in order to get the text in "c:\test.txt" into my String "test" in my module.
Thank you very much!
 
The VB Open commands should work. Is your text string greater then 255 characters? That is a limiting factor for access text data types.
 
I thought the maximum was 32k.
Anyway, could anybody give me the few lines of code it takes? PLEASE!
 
Hi!

This is from the VBA help;

Open "c:\test.txt" For Input As #1
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, test ' Read line into variable.
Loop
Close #1

This will read through your file sequentually til the EOF mark.

Enjoy!
Roy-Vidar
 
Roy can I thank you for reminding me to get back to basics. I have just been importing a lot of text files into Memo fields and then parsing them from there (a technique I use a lot) In my current project I have a lot of small text files so the basic file 'Open' method would of been much better and quicker.
It's sometimes easy to forget the basic methods and get bogged down in 'fancy' methods.
doh!
Regards
Trevor from www.accesswatch.co.uk
 

Users who are viewing this thread

Back
Top Bottom