VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Read / Load contents of a textfile into a listbox

by Marcel Wijnands (3 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

Reads / Loads contents of a textfile into a listbox

Inputs
filepath+filename and listbox name
Code Returns
returns contents of a textfile into a listbox
API Declarations
usage:
File2ListBox "c:\yourfile.txt", ListBox1

Rate Read / Load contents of a textfile into a listbox

Public Sub File2ListBox(sFile As String, oList As ListBox)
Dim fnum As Integer
Dim sTemp As String
 fnum = FreeFile()
 oList.Clear
 Open sFile For Input As fnum
  While Not EOF(fnum)
   Line Input #fnum, sTemp
   oList.AddItem sTemp
  Wend
 Close fnum
End Sub

Download this snippet    Add to My Saved Code

Read / Load contents of a textfile into a listbox Comments

No comments have been posted about Read / Load contents of a textfile into a listbox. Why not be the first to post a comment about Read / Load contents of a textfile into a listbox.

Post your comment

Subject:
Message:
0/1000 characters