Editing a text file

C

chinny03

I have a text file that looks like this:

Baker City
Greenhorn
Haines
Halfway
Huntington

I have a form where the user enters info and I need the values in the text
boxes to be concatenated together with the text file.

For example,
I have the text boxes names (txtBox1, txtBox2, txtBox3) I would need the
file to look like this:

txtBox1 Baker City txtBox2 Baker City txtBox3

I would need this throughout the entire length of the file.
 
J

Jack Leach

Take a look at some VBA File IO functions
(http://www.applecore99.com/gen/gen029.asp) for information on reading and
writing to text files.

When I have to work with text files at all, I'll generally utilize a temp
table to deal with the data rather than trying to do it directly with the
file. Load the file into the temp table, then use access to manipulate the
"records" (lines of the file). When you're done your temp table should
contain everything you want to put back in the file. The IO functions in the
link above will get you there.

A temp table for text files is generally two fields... a number (sequence)
that you order it by so you know everything lined up the way you want, and a
text for holding the line to be inputted/outputted to or from the file.

That said, you'll want some way to take the data of the control and its
value and putting it into a temp table. Do this for everything you need, and
then run your IO code to output the table to a file.

All that said... this seems an odd request. It seems as though there
should be an easier way to do what you're trying to do... text files aren't
the best in most cases. But, I don't know the situation, so...


hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top