Link to home
Start Free TrialLog in
Avatar of PeterErhard
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.FileName, Len(CommonDialog1.FileName) - (Len(CommonDialog1.DefaultExt) + 1)) & Mid(CommonDialog1.DefaultExt, 2) For Append      As #1
          For ID = 1 To ProgressBar1.Max

            Print #1, Query
         Next
         Close #1
Avatar of PockyMaster
PockyMaster
Flag of Netherlands image

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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial