Results 1 to 4 of 4

Thread: How do I assign a name to a saved file?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733

    How do I assign a name to a saved file?

    I am new to text file processing in VB. I am parsing a file that contains many reports. I wish to save each report as a separate text file. What is the syntax for that?

    Thanks,
    Jeff

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    I should probably reword this.

    After parsing the data I wish to save each report as a separate file. How do I save the text file in a specific directory and save it under a specific name?

  3. #3
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222
    Code:
    Dim FileNum as Integer
    Dim FilePath as String
    Dim FileName as String
    Dim Data as String
    
    Data = "Whatever data you wish to write"
    
    FilePath = "C:\"
    FileName = "DataFile1.dat"
    
    FileNum = FreeFile
    
    Open FilePath + FileName For Output as FileNum
    Print #FileNum, Data
    Close #FileNum
    If you want to append to the file, replace the Output keyword with the Append keyword

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Thanks Finn...

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