Append to Text File?

How can I open a text file and write (append) to it, beggining where I left off last time?
rrr333222Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JuiletteCommented:
'writing or reading data to or from a text file
'open for append adds the data to the end of file
'open for input opens the file for read only
'open for output opens the file and overwrites the file
'
'
Private Sub Command1_Click()

'this is the number of your file
Dim intFilenum As Integer

'set it to the next available free number
intFilenum = FreeFile

'this is your filename
Dim strFile As String
strFile = "A:\myfile.txt"

'this is the text you want to save (textbox)
Dim strText As String
strText = Text1.Text

'open the file for writing to as next freefile number

Open strFile For Append As intFilenum  'see above options
'write to the file
    Write #intFilenum, strText  'to read use  [input #filenum,strtext]

'close the file
Close intFilenum
   
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AristippusCommented:
Simple Example:
(Include within a procedure)


dim msg

msg="The text to append"

Open "c:\test.txt" For Append As 1

Print #1, msg

Close 1


 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.