Results 1 to 4 of 4

Thread: Output in .txt files

  1. #1

    Thread Starter
    Lively Member Patrice Bourdages's Avatar
    Join Date
    Jun 2000
    Location
    Quebec, Canada
    Posts
    83

    Question

    Hello you guru's :-)

    I need a little help with this one.

    I'm creating a program that will "create" or write program headers, body and footer.

    It gets complicated when I want to "write out" in ASCII format. I would need a bunch of Sub to write info in those ASCII files.

    Ex.: I'm creating a .txt file that will contain the code required to run a particular task.

    private sub header
    ' open output file (in write mode)
    ' start the process
    print "/*************************************************/"
    print "* Program..: " & strProgramFile
    print "*"
    print "* Author...: " & strAuthor
    print "*"
    print "* Date.....: " & strCreationDate
    print "/************************************************/;"
    ' close the output file for the moment
    end sub

    private Sub Body
    ' re-open the output file (in append mode)
    ' do my output stuff
    ' close the output file for the moment
    end sub

    etc...

    I simply don't know how to create that .txt file. Could someone proivde me the basic stuff so that I could go on.

    Sincerely,

    Patrice :-)

  2. #2
    Lively Member
    Join Date
    May 1999
    Location
    KC
    Posts
    72
    To create a text file, just open it in output mode. If the file does not exist, it is created, if it does exist, it is overwritten.

    Open "MyFile.txt" for Output As #1

    'Then print to the file:
    Print #1, "Text to print"

    'When you're done, close the file:
    Close #1

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Try This:

    Code:
    Private Sub Form_Load()
    Open "C:\test.txt" For Output Shared As #1
    Print #1, "HI"
    Close #1
    End Sub
    
    Private Sub Form_Click()
    Open "C:\test.txt" For Append Shared As #1
    Print #1, "HI"
    Close #1
    End Sub
    Hope this helps

  4. #4

    Thread Starter
    Lively Member Patrice Bourdages's Avatar
    Join Date
    Jun 2000
    Location
    Quebec, Canada
    Posts
    83

    Talking Thanks a Bunch

    Thank you very much you guys...

    Wasn't looking at the right place...

    Sincerely yours,

    Patrice :-)

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