473,511 Members | 14,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing to Multiple Files - VB6

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>

Sep 28 '06 #1
2 1983
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_******@hotmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.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>



Sep 29 '06 #2
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:
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_******@hotmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.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>
Sep 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2656
by: Dominik | last post by:
I am writing application which must download multiple files simultaneous. Initially I wanted to use multiple threads to achieve this task but later I heard that Net is "using" separate thread from...
6
10541
by: x. zhang | last post by:
Hi Guys, We know that we can use <input type=file ...> to upload one file per time to the server. My question is if there are some way to upload multiple files per time to the server. (Of...
2
6891
by: caro | last post by:
Hi I am trying to write two Select * statements to the same text file using bcp (from a stored procedure). But cannot find a way of appending to a file using bcp. Does anyone know if this...
7
2746
by: crowl | last post by:
Hi there, I am looking for a component allowing me uploading multiple files by my asp page. I have found several components achieving this by require a <input type="file" name="FileX"> field for...
4
312
by: galt_57 | last post by:
Hi, where can I find a comprehensive answer to the question of how a c program should be broken up into multiple files? I don't want abstract talk about interfaces -- I want a good detailed...
1
5825
by: toramadevi | last post by:
Hi ALL, I 'm using DevC++ for writing a C source code to create multiple files and folders under a directory.With the help of mkdir command i am able to get a bunch of 40 folders in the current...
10
3658
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
2
1984
by: ingavatne | last post by:
Hey! I am trying to write a c program that converts multiple files of one kind to similar files of anther kind. Do anyone have suggestions of how I can do this in a easy way and avoid writing ...
43
9837
by: bonneylake | last post by:
Hey Everyone, Well this is my first time asking a question on here so please forgive me if i post my question in the wrong section. What i am trying to do is upload multiple files like gmail...
4
4854
by: MoroccoIT | last post by:
Greetings - I saw somewhat similar code (pls see link below) that does mupltiple files upload. It works fine, but I wanted to populate the database with the same files that are uploaded to...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.