Hi. good day, can anyone help me please..I'm going to run an application which will get files in folder and store it to listbox,,but I'm always came up with this error: "User defined type not defined" please help me..give me another suggestion....heres my code: thanks..

Dim oFileSystem As New FileSystemObject
Dim oFolder As Folder
Dim oCurrentFile As File
Dim oFileColl As Files
Set oFolder = oFileSystem.GetFolder("C:\Files")
Set oFileColl = oFolder.Files
If oFileColl.Count > 0 Then
With lstFiles
For Each oCurrentFile In oFileColl
.AddItem oCurrentFile.Name
Next
.ListIndex = 0
End With
End If
Set oFileSystem = Nothing
Set oFolder = Nothing
Set oFileColl = Nothing
Set oCurrentFile = Nothing

You simply need to add Microsoft Scripting Runtime to your project from Project ---> references.

Rest all is fine . Hope that solves your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.