|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Writing to Multiple Files - VB6Hi,
I have an idea that I want to write to many (qty unknown untill run time but in the order of 5) text files as my application runs. They're log files dealing with different aspects of the application and will ultimately be sent to different users, hence why they have to be different files. I know that I want to be using the File System Object to manage files, but I don't know how to open many files, keep them open and write to them as and when required. The FSO is a collection, so I guess it should be possible but I could do with some hints or tips from you guys as to the best way to go about this. Cheers, <M> First, this is a dotnet group (VB 6 is pre-dotnet). Now for the answer
since I cringe when that's all I see is "Wrong NG." I'm not going to use FSO simply because it's too slow and different versions of Windows have slightly different versions of the scripting runtime engine. dim FileOutput(5) as long dim i as integer for i = 1 to 5 FileOutput(i) = freefile(1) open "Myfile_" & i & ".log" for output as FileOutput(i) next i When you write to a file, simply select the index in the FileOutput array that you want to use print #FileOutput(someindex), "This is output" You can either close the files individually (preferable) with Close FileOutput(i) or all at once with Close For further reference, a better NG for VB 6 questions is microsoft.public.vb.general.discussion. Mike Ober. Show quoteHide quote "<M>" <m_din***@hotmail.com> wrote in message news:1159477377.245210.182930@i42g2000cwa.googlegroups.com... > Hi, > > I have an idea that I want to write to many (qty unknown untill run > time but in the order of 5) text files as my application runs. They're > log files dealing with different aspects of the application and will > ultimately be sent to different users, hence why they have to be > different files. I know that I want to be using the File System Object > to manage files, but I don't know how to open many files, keep them > open and write to them as and when required. > > The FSO is a collection, so I guess it should be possible but I could > do with some hints or tips from you guys as to the best way to go about > this. > > Cheers, > > <M> > > Sorry for the posting in the wrong group. I didn't spot the mistake
untill after I posted. I subsequently did raise a new subject in the other group you mentioned. That solution looks ideal. Thanks very much for the help. <M> Michael D. Ober wrote: Show quoteHide quote > First, this is a dotnet group (VB 6 is pre-dotnet). Now for the answer > since I cringe when that's all I see is "Wrong NG." > > I'm not going to use FSO simply because it's too slow and different versions > of Windows have slightly different versions of the scripting runtime engine. > > dim FileOutput(5) as long > dim i as integer > for i = 1 to 5 > FileOutput(i) = freefile(1) > open "Myfile_" & i & ".log" for output as FileOutput(i) > next i > > When you write to a file, simply select the index in the FileOutput array > that you want to use > > print #FileOutput(someindex), "This is output" > > You can either close the files individually (preferable) with > > Close FileOutput(i) > > or all at once with > > Close > > For further reference, a better NG for VB 6 questions is > microsoft.public.vb.general.discussion. > > Mike Ober. > > > > "<M>" <m_din***@hotmail.com> wrote in message > news:1159477377.245210.182930@i42g2000cwa.googlegroups.com... > > Hi, > > > > I have an idea that I want to write to many (qty unknown untill run > > time but in the order of 5) text files as my application runs. They're > > log files dealing with different aspects of the application and will > > ultimately be sent to different users, hence why they have to be > > different files. I know that I want to be using the File System Object > > to manage files, but I don't know how to open many files, keep them > > open and write to them as and when required. > > > > The FSO is a collection, so I guess it should be possible but I could > > do with some hints or tips from you guys as to the best way to go about > > this. > > > > Cheers, > > > > <M> > > > >
Are optional parameters really an advisable thing to use ?
keypressed regex question Setting breakpoints in VB2005 Iterate a structure to get name and value Truly transparent label. How to find the position of the first dash in a string Converting a string to a Form object JavaScript, ASP, and VB :) Looking for a real working transparent picturebox |
|||||||||||||||||||||||