In that screenshot, you can see that my call to the function originated from Window1.Opening. If I click on Window1.Event.Opening, I can see the function call itself and verify the parameter values that I’m passing.
That parameter value has to be coming from somewhere. Did you follow my instructions above and inspect what’s happening to result in delFolders being True? Set a breakpoint on your call to RemoveEntireFolder and look at the values in the debugger.
Call RemoveEntireFolder(f,true,true) // remove entire folder and contiue if errors true both
If this is the function signature: Function RemoveEntireFolder (theFolder As FolderItem, delFolders As Boolean = False, continueIfErrors As Boolean = False) As Integer
The method is expecting the second parameter to be continueIfErrors. Now you made delFolders the second parameter! When adding new parameters it’s a better idea to append them to the end of the parameter list to avoid problems like this, especially when recursion is involved. The method may not be called from anywhere else in your program, but it calls itself!
I understood the problem, the last two parameters are reversed! It works by reversing the last two parameters! but I don’t understand why.
Maybe because I added an additional parameter in second position, it is always considered as the last arrived!
Here is how they are declared: