Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write to an existing file without overwriting what is in it using VB6?

Tags:

file

append

vb6

I need to write to a text file to record a set of scores. Every time I write to the text file, it overwrites what was originally in the file. Can someone tell me how to not let it overwrite what is there or how to make it start writing in an empty space?

like image 578
Emma Avatar asked May 11 '10 15:05

Emma


2 Answers

Open the file 'for append'.

This will erase the file:

Open "C:\path\to\file.txt" For Output As FILE

This will not erase the existing content:

Open "C:\path\to\file.txt" For Append As FILE
like image 57
Konerak Avatar answered Nov 06 '22 06:11

Konerak


Use text append for this

Normally append text

'Start append text to file
    FileNum = FreeFile
    Open "D:\45.txt" For Append As FileNum
    Print #FileNum, Text1.Text
    Close FileNum
'End

Saving to app path

'Start append text to file
    FileNum = FreeFile
    Open App.Path & "\45.txt" For Append As FileNum
    Print #FileNum, Text1.Text
    Close FileNum
'End
like image 21
Asitha Yomal Avatar answered Nov 06 '22 07:11

Asitha Yomal