Results 1 to 2 of 2

Thread: Open

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Post

    How can i open a text file into a TextBox?
    Not RichTextBox!
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Guest

    Post

    Ok, when you have placed a textbox on your form.
    Set by the properties of the textbox by Multiline = True

    And place this code under the command or whatever event.

    Code:
      Dim sData As String
      Dim iFile As Integer
      
      iFile = FreeFile
      
      ' place your own directory and file here
      ' if the file does not exist your will get
      ' error 53 "file not found"
      Open "C:\File.Txt" For Input As iFile
    
      While Not EOF(iFile)
        ' read the all the lines here
        Line Input #iFile, sData
    
        ' place the line in the textbox and ending with a 
        ' Chr(13) & Chr(10) = enter
        Text1.Text = Text1.Text & sData & Chr(13) & Chr(10)
      Wend
      Close iFile
    I hope this will work for you..

    -Kayoca Mortation

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