Load a List box with Lines from a File

Category:
Files and Directories
Type:
Snippets
Difficulty:
Beginning
Author:
Gavin Bollard

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
This simple routine loads a list box from a file... (except blank lines). I was using it to read in a list of directories created using DIR /S /B >> FILENAME.TXT for comparison. There should be other uses for it too. 'SAMPLE USAGE... Sub Command1_Click 'This Example Expects a list box called LstElements 'and a File called C:\TEMP\TEST.TXT LoadListFromFile LstElements, "C:\TEMP\TEST.TXT" End Sub

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: