Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleLoad a ListBox using the lines in a file using Split
Keywordsadditem, ListBox, line, file, Split
CategoriesControls
 
Use the Input command to read the entire file. Use Split to break it into lines. Then add each line to the ListBox.
 
Private Sub cmdLoad_Click()
Dim fnum As Integer
Dim file_contents As String
Dim lines As Variant
Dim i As Integer

    ' Grab the file's contents.
    fnum = FreeFile
    Open txtFile.Text For Input As #fnum
    file_contents = Input$(LOF(fnum), #fnum)
    Close #fnum

    ' Split the lines apart.
    lines = Split(file_contents, vbCrLf)

    ' Load the list.
    lstLines.Clear
    For i = LBound(lines) To UBound(lines)
        lstLines.AddItem lines(i)
    Next i
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated