Click here to Skip to main content
15,892,005 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: email application in vb without the use of MAPI controls Pin
Richard MacCutchan3-Mar-11 2:20
mveRichard MacCutchan3-Mar-11 2:20 
GeneralRe: email application in vb without the use of MAPI controls Pin
K Suresh Nair3-Mar-11 3:18
K Suresh Nair3-Mar-11 3:18 
GeneralRe: email application in vb without the use of MAPI controls Pin
Richard MacCutchan3-Mar-11 3:23
mveRichard MacCutchan3-Mar-11 3:23 
AnswerRe: email application in vb without the use of MAPI controls Pin
_Erik_3-Mar-11 2:30
_Erik_3-Mar-11 2:30 
AnswerRe: email application in vb without the use of MAPI controls Pin
Simon_Whale3-Mar-11 2:57
Simon_Whale3-Mar-11 2:57 
GeneralRe: email application in vb without the use of MAPI controls Pin
K Suresh Nair3-Mar-11 3:12
K Suresh Nair3-Mar-11 3:12 
QuestionVisual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis761-Mar-11 22:59
Memphis761-Mar-11 22:59 
AnswerRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number [modified] Pin
_Erik_1-Mar-11 23:26
_Erik_1-Mar-11 23:26 
This is VB 6, isn't it? Some tips:

1. Try to avoid variant types, they are really slow. FolderName, FolderPath, FolderDate, FolderLMod, FolderLAcc, FolderSize are variant in your snippet. Actually, you don't need them, becouse you will have this information in the fFolder properties.
2. Do not open a new recordset every time you want to add a new row. Open it before calling the function and pass it as a parameter.
3. It is usually better to do the recursive call after you have processed the current folder, I mean, add the folder you are processing, and then do the recursive calls for each subfolder into it.
4. Do not declare "i" variable into your function, just pass it as a parameter, so you will be able to increase its value on each call.

This way, your sub would look like as follows:

VB
Sub SearchFolders(rst as Recordset, strDir as String, i as integer, objFSO As FileSystemObject)
    Dim fFolder As Folder, sFolder As Folder
    Set fFolder = objFSO.GetFolder(strDIR)

    With rst
        .AddNew
        !FolderId = i
        ' The rest of the assingments here, using fFolder variable
        .Update
    End With

    ' Do not close the recordset here, just invoke recursively
    For Each sFolder in fFolder.SubFolders
        SearchFolders rst, sFolder.Path, i + 1, objFSO
    Next
End Sub


So all you have to do is add another function which will initialize the extension paramaters (rst, i and objFSO) before calling this, and then dispose them when this Sub is finished:

VB
Sub BeginSearchFolders(string path)
    Dim objFso as New FileSystemObject
    Dim rst as Recordset
    'Initialize rst here and invoke:

    SearchFolders(rst, path, 1, objFso)

    ' Dispose objects here
    rst.Close
    ' etc
End Sub


Edit: Forgot to add the bold parameter in the recursive call.

modified on Wednesday, March 2, 2011 8:56 AM

GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 6:24
Memphis762-Mar-11 6:24 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 14:02
Memphis762-Mar-11 14:02 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
_Erik_3-Mar-11 0:32
_Erik_3-Mar-11 0:32 
AnswerRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Luc Pattyn2-Mar-11 1:39
sitebuilderLuc Pattyn2-Mar-11 1:39 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 6:25
Memphis762-Mar-11 6:25 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Luc Pattyn2-Mar-11 6:29
sitebuilderLuc Pattyn2-Mar-11 6:29 
AnswerRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Dave Kreskowiak2-Mar-11 9:28
mveDave Kreskowiak2-Mar-11 9:28 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 12:05
Memphis762-Mar-11 12:05 
QuestionBIFF7 Conversion Pin
Dominick Marciano1-Mar-11 10:13
professionalDominick Marciano1-Mar-11 10:13 
AnswerRe: BIFF7 Conversion Pin
Dave Kreskowiak1-Mar-11 15:11
mveDave Kreskowiak1-Mar-11 15:11 
GeneralRe: BIFF7 Conversion Pin
Thomas Krojer1-Mar-11 21:23
Thomas Krojer1-Mar-11 21:23 
QuestionIntercept e Send ALT+F1 Pin
starcomsis1-Mar-11 5:24
starcomsis1-Mar-11 5:24 
AnswerRe: Intercept e Send ALT+F1 Pin
Dave Kreskowiak1-Mar-11 8:58
mveDave Kreskowiak1-Mar-11 8:58 
GeneralRe: Intercept e Send ALT+F1 Pin
starcomsis1-Mar-11 9:20
starcomsis1-Mar-11 9:20 
GeneralRe: Intercept e Send ALT+F1 Pin
Dave Kreskowiak1-Mar-11 14:46
mveDave Kreskowiak1-Mar-11 14:46 
QuestionHow to set parallel port in VB programming? Pin
saathis1-Mar-11 4:22
saathis1-Mar-11 4:22 
AnswerRe: How to set parallel port in VB programming? Pin
DaveAuld1-Mar-11 4:57
professionalDaveAuld1-Mar-11 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.