Click to See Complete Forum and Search --> : Loading Directory Conents Into Array
Eric M
Nov 26th, 1999, 01:20 AM
How would I load a directorys contents into an array cuase im trying to list the documents list thats in windows start menu in a menu and all I really need is to be able to list the contents in an array and I can do the rest.. Thanx
Aaron Young
Nov 26th, 1999, 12:01 PM
Use the Dir Function:
Private Sub Command1_Click()
Dim aDir As Variant
Dim iIndex As Integer
aDir = ListDir("C:\*")
For iIndex = 0 To UBound(aDir)
List1.AddItem aDir(iIndex)
Next
End Sub
Private Function ListDir(ByVal sPath As String) As Variant
Dim aList() As String
Dim sDir As String
Dim iIndex As Integer
sDir = Dir(sPath)
While Len(sDir)
ReDim Preserve aList(iIndex)
aList(iIndex) = sDir
iIndex = iIndex + 1
sDir = Dir
Wend
ListDir = aList
End Function
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.