Results 1 to 5 of 5

Thread: Write/Read Commands

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    8

    Write/Read Commands

    Hey All,
    I need to know the basic code on how to write to a text file using a textbox, and then retrieve it back when i do a search from a texbox.

    Any help would be great

    Thanks Jason

  2. #2
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    To write to the file:

    VB Code:
    1. Open "C:\test.txt" For Output As #1
    2.     Print #1, "Say something here"
    3. Close #1

    I don't remember the code for retrieving from the text file, as I haven't found much use for it ever since I found the RichTextBox.SaveFile and RichTextBox.LoadFile functions.

    My advice would be to use the rich text box instead, it's much easier.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    8
    Thanks hothead.
    On your advise what would be the code to write/read to this richtextbox.
    example for writing
    ======================
    Open "C:\test.tft" For Output As #1
    Print #1, "Say something here"
    Close #1
    =======================

    How would you read ??

    Thanks

  4. #4
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    You could do something like:

    Dim strYourText As String
    Open "C:\detlog.txt" For Input As #1
    Do Until EOF(1) = True

    Input #1, strYourText

    Text1.Text = Text1.Text & strYourText
    Loop

    All depends on how you want to read it.

  5. #5
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    The syntax to write to a file using a rich text box is different from that of a regular text box. It would be something like this:

    VB Code:
    1. RichTextBox1.SaveFile App.Path & "\Test.txt", RTF_TEXT

    And here's how to read from the file:

    VB Code:
    1. RichTextBox1.LoadFile App.Path & "\Test.txt", RTF_TEXT

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