Something else must be going on here. Do you have other calls to this function that you haven’t updated for the new parameter?
Set a breakpoint on the first line of the function and check the Stack pane of the debugger to make sure that you’re seeing what you think you’re seeing.
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!
If you want a real answer instead of all kind of guesses, you should put the complete code of the function. Maybe you change the value of delFolders somewhere else.
If not, Try to put a break BEFORE the call to the function and see if you are sending the True value, Put another break inside the function right at the top and check what are you getting.
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:
As I said in my response, it’s because the method is recursive. When it calls itself, it’s expecting continueIfErrors in the second parameter, not the third.
This demonstrates the dangers of optional parameters, especially use of more than one. Had the parameters not been optional, I think the compiler would have caught the issue.