Lines in text file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Lines in text file

  1. #1
    Join Date
    Mar 2005
    Posts
    5

    Lines in text file

    Hey, I need to load text from a textbox into my vb6 form but the thing is I want to you use a timer that loads the 1st line of text then makes the Text1.text = to that 1st line in the file. Then after the timer runs again it should do that same but just load the 2nd line ...ect. It should stop when it's at the end of file.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I would declare a module-level variable to hold the file handle and open the file when the app starts. Then in the Timer event, simply read a line from the file:
    Code:
    ' hFile is your module-level handle variable
    Line Input #hFile, sText
    Text1.Text = sText
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    and do not forget to disable the timer and close the file at EOF...

    Replace
    Text1.Text = sText
    with
    Text1.SelStart = len(text1.text) <= put the insertion point at the end of the text box
    Text1.selText = sText <= add a new line

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center