|
-
Feb 22nd, 2000, 01:36 AM
#1
Thread Starter
Member
I use the follow function to generate a text file:
FileNumber = FreeFile
Open "c:/Myfile" For Output As #FileNumber
Write #FileNumber, "This is a sample."
Close #FileNumber
this file work fine at my machine after go
through the VB set up procedure. but the problem is that after the program is installed in an another machine, the "Myfile" is no where to be found. anybody has idea what is going wrong?
Thanks a lot.
-
Feb 22nd, 2000, 01:43 AM
#2
Lively Member
Try this instead
______________________
Open "c:\myfile.txt" For Output As #12
Print ascii; file
Print #12, "Information you want in file"
Close #12
The print ascii; file command is why your having the problem
Hope this helps
Brooke
-
Feb 22nd, 2000, 02:17 AM
#3
Hyperactive Member
I would say that there is something else wrong with it. I've used code just like he does and I've never had a problem. Are you sure that the code is being run? From what I remember (and I could be wrong), the main difference between Write and Print is Print just dumps the string or text to the file, it doesn't do any formatting etc. The Write would put quotes around it etc. I'm just wondering whether the code is being run. Just Open file for Output as #FileNumber should create the file.
-
Feb 22nd, 2000, 03:09 AM
#4
Lively Member
Open "c:\myfile" For output As x
Print #x, "hello"
Close dikla
------------------
shachar shaty
israel
-
Feb 22nd, 2000, 06:15 AM
#5
Frenzied Member
Does the fact that he has a forward slash instead of a backslash have anything to do with it?
i.e. he has:
Open "c:/Myfile"...
instead of:
Open "c:\Myfile"...
Just an observation,
~seaweed
-
Feb 22nd, 2000, 07:15 AM
#6
Hyperactive Member
I believe I had that problem as well. It would give me a file not found error. To solve it, I did this:
Open "MYFILE.txt" For Random As #Freefile
Close #Freefile
Open "MYFILE.txt" For OutPut As #Freefile
blah blah blah
This would open the file and close it immediately then open it again. The cool part is that if you open it random, then it will create the file if it doesn't exist. Thus, if it exists, great. If it doesn't, it will be created, closed, then opened again for output.
-
Feb 23rd, 2000, 01:00 PM
#7
Thread Starter
Member
Thank You Very Much Indeed.
I believe I had that problem as well. It would give me a file not found error. To solve it, I did this:
Open "MYFILE.txt" For Random As #Freefile
Close #Freefile
Open "MYFILE.txt" For OutPut As #Freefile
blah blah blah
This would open the file and close it immediately then open it again. The cool part is that if you open it random, then it will create the file if it doesn't exist. Thus, if it exists, great. If it doesn't, it will be created, closed, then opened again for output.
That is the solution. You save me a lot of time.
-
Feb 23rd, 2000, 01:00 PM
#8
Thread Starter
Member
Thank You Very Much Indeed.
I believe I had that problem as well. It would give me a file not found error. To solve it, I did this:
Open "MYFILE.txt" For Random As #Freefile
Close #Freefile
Open "MYFILE.txt" For OutPut As #Freefile
blah blah blah
This would open the file and close it immediately then open it again. The cool part is that if you open it random, then it will create the file if it doesn't exist. Thus, if it exists, great. If it doesn't, it will be created, closed, then opened again for output.
That is the solution. You save me a lot of time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|