Computing.Net > Forums > Programming > VB: TXT lines to ListItem

VB: TXT lines to ListItem

Reply to Message Icon

Original Message
Name: astroraptor
Date: December 8, 2003 at 13:59:44 Pacific
Subject: VB: TXT lines to ListItem
OS: Windows 2000 Pro
CPU/Ram: 1.6GHz/512Mb
Comment:

Hi, how can I input each line from a text file to a ListItem? Thanks in advance.


Report Offensive Message For Removal

Response Number 1
Name: Stuart
Date: December 8, 2003 at 15:40:20 Pacific
Subject: VB: TXT lines to ListItem
Reply: (edit)

List1.AddItem TextItem, a

The index a is optional. TextItem is a text string containing the line of text.

Stuart



Report Offensive Follow Up For Removal

Response Number 2
Name: astroraptor
Date: December 8, 2003 at 16:41:50 Pacific
Subject: VB: TXT lines to ListItem
Reply: (edit)

This doesn't tell me much, how would I implement this in the program?


Report Offensive Follow Up For Removal

Response Number 3
Name: StuartS
Date: December 8, 2003 at 17:38:36 Pacific
Subject: VB: TXT lines to ListItem
Reply: (edit)

Open the file for input. Read each line into a text variable. Add the text variable to the list. Go back and read the next line till you get EOF.

Dim TextLine
Open "TESTFILE" For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
List1.AddItem TextItem ' Add item to list
Loop
Close #1 ' Close file.

Look up Line Input in the VB help files.

Stuart


Report Offensive Follow Up For Removal

Response Number 4
Name: astroraptor
Date: December 8, 2003 at 21:22:34 Pacific
Subject: VB: TXT lines to ListItem
Reply: (edit)

Thanks for the help!


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: VB: TXT lines to ListItem

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software