filling an array with filenames

hi how do u fill a dynamic array with file names, i have this code but it fills a listbox, how do i modify this to fill an array.

And pass that array over a winsock control i.e send data.







Sub ScanDir(ByVal vsPath As String, lstList As ListBox)

'=========================================================
'Purpose    Populate a given listbox with the names of all
'           files in a given directory.
'Entry      vsPath - full pathname of the directory to
'           search.
'           lstList - the list box to populate
'Exit       None, but contents of list box will have been
'           modified.
'Comments   One of Marks routines!

Dim sNextEntry As String
Dim iLen As Integer
Dim iAttr As Integer

'Constants for use with GetAttr():
Const ATTR_NORMAL = 0       'Normal file
Const ATTR_READONLY = 1     'Read-only file
Const ATTR_HIDDEN = 2       'Hidden file
Const ATTR_SYSTEM = 4       'System file
Const ATTR_VOLUME = 8       'Volume label
Const ATTR_DIRECTORY = 16   'MS-DOS directory
Const ATTR_ARCHIVE = 32     'File has changed since last back-up

'Define types of files etc to search for
iAttr = ATTR_NORMAL + ATTR_READONLY + ATTR_HIDDEN + ATTR_SYSTEM

'Make sure path is terminated with a \ character
iLen = Len(vsPath)
If iLen > 0 And Mid$(vsPath, iLen, 1) <> "\" Then vsPath = vsPath & "\"

'Get first entry in directory, initialises Dir()
sNextEntry = Dir(vsPath, iAttr)

'Now fetch all other entries
While Len(sNextEntry)

    'Only include 'reasonable' filenames
    If sNextEntry <> "." And sNextEntry <> ".." Then
        lstList.AddItem sNextEntry
    End If

    'Fetch next filename
    sNextEntry = Dir
Wend

End Sub

RazaHasnainAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richie_SimonettiIT OperationsCommented:
dim idx as integer
dim ffiles() as string
'Now fetch all other entries
While Len(sNextEntry)

   'Only include 'reasonable' filenames
   If sNextEntry <> "." And sNextEntry <> ".." Then
       redim preserve ffiles(idx)
       ffiles(idx)= sNextEntry
       idx=idx+1
   End If

   'Fetch next filename
   sNextEntry = Dir
Wend

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.