Results 1 to 4 of 4

Thread: Creating files...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    115

    Creating files...

    How can I create a file (.txt) using coding?

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Creating files...

    Here ya go
    Code:
    Dim ff As Integer
        ff = FreeFile
            Open App.Path & "\someFile.txt" For Append As #ff
                Print #ff, Text1.Text
                Close #ff

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    115

    Re: Creating files...

    Thanks.

  4. #4
    Addicted Member
    Join Date
    Mar 2007
    Posts
    183

    Re: Creating files...

    You actually want a SAVED text file, don't you? Well, here's what you do:

    First, create a RichTextBox, name it rtfTextToSave, set its Text property to whatever text you want the text file to hold, then make it invisible.
    Last, copy and paste the following code into the procedure you want to save the text file.

    VisualBasic60 Code:
    1. Dim sFile
    2. 'replace c:\yourFile.doc with the file name, extension  and path you want
    3. sFile = "c:\yourFile.doc"
    4. rtfTextToSave.SaveFile sFile

    If it's a text file you want to create, tell your users to open up Microsoft Word (actually the word processor to use depends on the extension you use, and it has to be a processor that can save as plain text) and save it as a plain text file. OK, Visual Basic won't actually create the text file, as you can see. That means more work for the users.

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