Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Populating a listbox


Message #1 by "Fredrik" <fredrik.flyghed@o...> on Mon, 15 Jan 2001 12:38:07 -0000
Personally, i'd use the Scripting.FileSystemObject to do this.  There are other ways
to do it in VB, but i'm partial to an object model.  Set a reference to the
Microsoft Scripting Runtime and the use this code:

Public Function GetFileList(lstBox as ListBox, sDirectory As String) As Boolean
Dim FSO as scripting.filesystemobject
dim oFolder as scripting.folder
dim i as integer
  
set fso = new scripting.filesystemobject
 
set ofolder = fso.getfolder(sdirectory)
 
for i = 0 to ofolder.files.count - 1
  lstBox.AddItem ofolder.files(i).Name
next 
 
set ofolder = nothing
set fso = nothing

GetFileList = True

End Function

hope that helps,

john

  Return to Index