Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two files open for output?

Status
Not open for further replies.

demoniac

Programmer
Jun 14, 2001
63
US
Hello :)

I'm having a problem when I try to have two files open at the same time, both for output. When it goes to open the second file it tells me that the file is already open. (I set both files = freefile too). Is it possible to do this?

Thanks :eek:)
demoniac
 
I think you can do that, but you need to set the open them between doing freefile :

handle1 = freefile
open "xxx" for output as handle1
handle2 = freefile
open "yyy" for output as handle2

Da.
 
I think you can do that, but you need to set the open them between doing freefile :

handle1 = freefile
open "xxx" for output as handle1
handle2 = freefile
open "yyy" for output as handle2

Dan.
 
That was it! I just had my freefile declarations right next to each other. Awesome, that was a huge help. ;)

Thanks,
demoniac :eek:)
 
Yeah, it odd how that works. FreeFile will return the next available filehandle, but it won't actually lock it untill you use it (i.e. open a file with it). I'm of the opinion that if you ask the OS for a file handle (i.e. calling freeFile) and the OS gives you a handle, it should be yours and not handed out again on the next call to FreeFile . . . but thats just me. ;-) - Jeff Marler B-)
 
I don't think it is just you, I agree. Once you have asked for a handle and been allocated one it makes no sense to hand it out again if the file has not been opened, but I guess we should be used to VB not nessecarily doing the sensible thing...

Dan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top