Results 1 to 8 of 8

Thread: create a textfile with textbox data

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    51

    Question

    How can i create a textfile that include the data of two
    textboxes on my form and save it on a disk?

  2. #2
    Addicted Member
    Join Date
    Jul 1999
    Location
    Saudi Arabia, Gulf side, Qatif
    Posts
    142
    You can use some thing like this:

    mytxtfile = App.Path & "\txtfile.txt"
    Open mytxtfile For Output As #1 ' Open file for input.
    txttosave = text1.Text
    Write #1, txttosave

    Close #1
    ,,,,,,,,,,,,,,,,,,
    Try and work arround
    Regards

  3. #3
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Wink

    The old way to do this would be to use File I/O or Input/Output, but the way that Microsoft would like you to do it now is to use File System Objects.

    First, you need to add a referrence to the Microsoft Scripting Runtime component. Having done that, declare the following variable:

    Code:
    Dim FSys As New FileSystemObject
    Then the function that you use to write to the text file will be

    Code:
    Dim OutStream as Textstream
    Set OutStream = FSys.CreateTextfile("C:\windows\mytext.txt")
    Outstream.Write(Text1.text & Text2.text)
    'and to finish off, save system resources by clearing
    'OutStream - not necessary, but a good habit...
    Set OutStream = Nothing
    Hope that helps :-) Run a search on File System Objects and you should get more help if you need it.

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    51

    Question lines

    how can i set data of textbox 1 in line 1
    and data of textbox to line 2 of an created txtfile?

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    51

    Question ????

    To put data from one textbot into a txtfile is easy
    but how can i put data into 2 seperatet lines from 2 seperatet text boxes?????????

  6. #6
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Unhappy Is this what u mean?

    Code:
    Dim OutStream as Textstream
    Set OutStream = FSys.CreateTextfile("C:\windows\mytext.txt")
    Outstream.Write(Text1.text & vbCrLf & Text2.text)
    'and to finish off, save system resources by clearing
    'OutStream - not necessary, but a good habit...
    Set OutStream = Nothing

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    51
    Nope...it doesnt work!
    any else ideas?

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    51
    its very important!!!

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