Thread: Recursive Subs?
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Recursive Subs?

Recursion is as when a procedure calls itself. It can be an extremely useful
technique, but has to be used with care.

The biog advantage is that it allows you to process when you have absolutely
no idea how many levels of your particular item will occur, and so if you
are processing a data type, and amongst that you find another set of that
datatype, you can just branch out of your current processing, process the
new item by calling itself, and then pick up where you were at the end. And
this can be done a number of times.

The best example I have is a VBScript that deletes files from the temp
folder. It builds an array of files to delete. It start in the temp
directory, and adds to the array. If one of the files is a directory, it
recursively calls itself for this new directory, and so on. Thus, I don't
have to do any testing on the number of sub-folders, and sub-folders of
sub-folders, etc.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ExcelMonkey " wrote in message
...
Can someone explain to me what recursive subs do. Mu understanding is
that it is a sub that in effect calls itself. Why would you ever need
this? What woudl be an example of this?


---
Message posted from http://www.ExcelForum.com/