Results 1 to 4 of 4

Thread: how to create text file?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    32
    la! how to create a simple .txt file??
    thank You in advance.

    Arnas
    VB6

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'writing or reading data to or from a text file
    'open for append adds the data to the end of file
    'open for input opens the file for read only
    'open for output opens the file and overwrites the file
    '
    '
    Private Sub Command1_Click()
    
    'this is the number of your file
    Dim intFilenum As Integer
    
    'set it to the next available free number
    intFilenum = FreeFile
    
    'this is your filename
    Dim strFile As String
    strFile = "A:\myfile.txt"
    
    'this is the text you want to save (textbox)(string)(etc)
    Dim strText As String
    strText = Text1.Text
    
    'open the file for writing to as next freefile number
    
    Open strFile For Append As intFilenum  'see above options
    'write to the file
        Write #intFilenum, strText  'to read use  [input #filenum,strtext]
    
    'close the file
    Close intFilenum
        
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Hehe Joe, making it all hard for the guy to understand ;].

    Code:
    Open "C:\file.txt" For Output As #1 'create the file
    Print #1, "This is what is going to be in the text file!" 'Write stuff inside the text file
    Close #1 'Close the file
    If you want it in quotes:

    Code:
    Open "C:\file.txt" For Output As #1 'create the file
    Write #1, "This is what is going to be in the text file!" 'Write stuff inside the text file
    Close #1 'Close the file

  4. #4
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    You might as well teach him right the first time.
    This space for rent...

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