Results 1 to 6 of 6

Thread: HOw do i read from a text file into a text box?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52

    Question

    Hello,
    If i have a text box (Or RTf box as the case may be) how do i go about reading the contents of a either *.rtf or *.txt file on form initialisation? I want the output to appear in the txtbox on my form.

    Any ideas anyone?

    regards
    M.



  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    throw a microsoft RichTextBox control on your form and add this code:

    Code:
    Private Sub Form_Load()
    RichTextBox1.LoadFile MYFILE, Rtf
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52
    Thanks for the tip, however for some reason this line

    rtbMotd.LoadFile c:\test.txt, Rtf

    returns an error.


    Tips?


    M.

  4. #4
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    You need to put quotes round the file path.

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52
    Ur a legend. thankyou.

  6. #6
    Guest
    For the flags:

    rtfRTF - RichTextBox format
    rtfText - regular text format

    RichTextBox1.LoadFile MYFILE, rtfRTF

    The flag Jop gave is wrong .

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