I 've coded a subroutine to create a text file (in this case a xml file)
which sometimes holds a size of 500 - 900 KB. While the subroutine works
efficiently for small file size (up to 50 KB) I noted a worse efficiency in
case of large file size (up to 10 minutes of calculation time).
This is the routine :
Set fso = CreateObject("Scripting.FileSystemObject")
Set xmlFile = fso.CreateTextFile(FilePath, True)
DO
xmlFile.Write "some text" & vbCrLf
LOOP UNTIL ..
xmlFile.Close
While debugging I've noted that the execution of line : xmlFile.Write ...
takes more and more time as the text file has grown lager.
Is there a more efficient way to create the text file ?
Regards,
Oscar
Jezebel - 14 Mar 2006 10:13 GMT
1. Don't use the Scripting object. The native file commands are simpler,
quicker, and more reliable.
2. Construct the file in memory then write it in one operation:
Dim pFileNum as long
Dim pFileText as string
Do
pFileText = pFileText & "sometext" & vbCr
Loop until ...
pFileNum = freefile
open FilePath for output as pFileNum
Print #pFileNum, pFileText
Close #pFileNum
>I 've coded a subroutine to create a text file (in this case a xml file)
>which sometimes holds a size of 500 - 900 KB. While the subroutine works
[quoted text clipped - 20 lines]
> Regards,
> Oscar
Oscar - 14 Mar 2006 14:44 GMT
Hi Jezebel,
I've done that but the performance didn't improve at all.
Oscar
> 1. Don't use the Scripting object. The native file commands are simpler,
> quicker, and more reliable.
[quoted text clipped - 36 lines]
>> Regards,
>> Oscar
Karl E. Peterson - 14 Mar 2006 18:58 GMT
> I 've coded a subroutine to create a text file (in this case a xml
> file) which sometimes holds a size of 500 - 900 KB. While the
> subroutine works efficiently for small file size (up to 50 KB) I
> noted a worse efficiency in case of large file size (up to 10 minutes
> of calculation time).
This multipost was answered, very well, elsewhere... <sigh>

Signature
Working without a .NET?
http://classicvb.org/