Results 1 to 10 of 10

Thread: Creating a Text File

Threaded View

  1. #9
    Hyperactive Member doctrin13th's Avatar
    Join Date
    Sep 2008
    Posts
    303

    Re: Creating a Text File

    Quote Originally Posted by DeanM View Post
    TestDate = Now
    FilePath = "C:\xyz"
    FileName = Box + ", " + TestDate + ".txt"
    filelocation = FilePath + FileName

    Open filelocation For Append As #1
    Print #1, Text1.Text
    Close #1
    [/CODE]
    Like Rhinobull said, format the date before using it. And I assume you want the complete one. I think this should do it:

    Code:
    TestDate = Format(Now, "Long Date")
    And I believe this one would raise an error:

    Code:
      Open filelocation For Append As #1
          Print #1, Text1.Text
      Close #1
    It is because of the line filelocation = FilePath + FileName. <Look here.. FilePath = "C:\xyz", FileName = Box + ", " + TestDate + ".txt"

    Supposing that Box is "K5" and TestDate is "15-06-10 4-25 PM" (as Spoo recommended) then FileName would be "K5, 15-06-10 4-25 PM.txt"

    Now FilePath + FileName would be "C:\xyzK5, 15-06-10 4-25 PM.txt" which will result to error or to an unexpected path and file name.

    Maybe you mean
    Code:
    filelocation = FilePath + "\" + FileName
    Lastly, I would recommend using "&" instead of "+" in connecting strings.
    Last edited by doctrin13th; Jun 30th, 2010 at 12:01 AM.

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