Bad File name or number

T

thorn2fish

I had a small subroutine where I read one text file and wrote to another. It
worked fine, but then I wanted to break the write (Print statement) out
various subroutines. Now I am receiving error:
Run-Time error '52':
Bad File name or number

Any thoughts on how to acomplish this? I want to open the input and output
files in the main sub, and then read/write in various sub-routines.
 
M

mudraker

without seeing your code it's hard to give a specific answer

If you use commands like this
Print #1, "This is a test" ' Print text to file.

you probally need a glabal variable to hold your free file number an
then use that variable within each sub routine

use this to get a free file numer
dim iFF as integer
iFF = FreeFile

then use variable in command
Print #myVariable, "This is a test" ' Print text to file
*-Post posted before response, posts merged!*
Oops typo in my previos reply
Print #myVariable, "This is a test" ' Print text to file.

should be
Print #iFF, "This is a test" ' Print text to file

--
mudrake

If my reply has assisted or failed to assist you I welcome you
Feedback.

www.thecodecage.co
 
T

thorn2fish

You would think I would know better. I sat here trying to execute just the
subroutine instead of the main sub. It is working correctly.

Thanks for the qucik response though!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top