PeterErhard
asked on
Writing to a text file
I'm using the following code below, which works fine, but is there someway I can automatically write to another file when the size of the initial one reaches 400KB and so on, so I could finish up with 10 400KB files rather than one 4MB file?
CommonDialog1.ShowSave
DoEvents
If CommonDialog1.FileName <> "" Then
Open Left(CommonDialog1.FileNam e, Len(CommonDialog1.FileName ) - (Len(CommonDialog1.Default Ext) + 1)) & Mid(CommonDialog1.DefaultE xt, 2) For Append As #1
For ID = 1 To ProgressBar1.Max
Print #1, Query
Next
Close #1
CommonDialog1.ShowSave
DoEvents
If CommonDialog1.FileName <> "" Then
Open Left(CommonDialog1.FileNam
For ID = 1 To ProgressBar1.Max
Print #1, Query
Next
Close #1
You could count the number of bytes in Query, and when it exceeds your limit, close the file, and write the rest
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.