Results 1 to 8 of 8

Thread: easy but no quite

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    brooklyn
    Posts
    48

    Post

    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.

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Posts
    81

    Post

    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

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    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.

  4. #4
    Lively Member
    Join Date
    Feb 2000
    Posts
    120

    Post

    Open "c:\myfile" For output As x
    Print #x, "hello"

    Close dikla

    ------------------
    shachar shaty
    israel

  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    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


  6. #6
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    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.

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    brooklyn
    Posts
    48

    Post 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.

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    brooklyn
    Posts
    48

    Post 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
  •  



Click Here to Expand Forum to Full Width