Wednesday, July 25, 2007

Visual Basic Function - To Search Or List Folder And Subfolder Content

Sample programme to listing data file and booklet names(including Bomber Folder)

To listing all the data files and booklets in the given way this includes bomber booklets as well. If lone booklet name necessitates to be printed then notice the line in data file listing. If lone data file name necessitates to be printed then notice the line in booklet listing

The mistakes have got to be handled from the career function, this mathematical mathematical mathematical function will throw the mistake with a textual matter "error from Functions.ListFolders ".

This function listings all the data files and booklets in debug window. If you desire to dwell in a collection. usage a seperate social class and usage private faculty degree variables to add it to hte collection.

This is a recursive function. Modifications to this mathematical function should be taken with attention using proper breakage of recursion.

'***************************************************************

'* Purpose : Get the listing of points from the folder

'*

'* Inputs : strPath(String) Way to folder

'*

'* Returns : listing of points in the folder

'* '****************************************************************

Public Bomber ListFolders(strFolder As String)

Dim fold up up As Scripting.Folder

Dim foldSub As Scripting.Folder

Dim fil As File

Dim fso As New FileSystemObject

Dim strOutput As String

On Mistake GoTo ErrTrap

Set fold = fso.GetFolder(strFolder)

For Each fil In fold.Files

'to acquire data file name

Debug.Print fil.Path

DoEvents

Next

For Each foldSub In fold.SubFolders

'to acquire booklet name

Debug.Print foldSub.Path

DoEvents

ListFolders foldSub.Path

Next

ErrTrap:

If Err Then

Err.Raise Err.Number, _

, "Error word form Functions.ListFolders " _

& Err.Description

End If

End Sub

Note: Add mention to Microsoft Scripting runtime for using Scripting.Folder

For more than mathematical functions related to vb6 delight visit http://www.vbknowledgebase.com/webapp/Guest/Home/Home.aspx?GroupCode=6

you may happen other articles related to vb scheduling also at http://www.vbknowledgebase.com

No comments: