Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default General question

Can anyone tell me the use of calling a sub inside itself.... please
Just some exemple to understand the uses
Thx for your help!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default General question

Hi David
one reason is the use for recursive algorithms. e.g. calculation of the
factorial (e.g. 5! =1*2*3*4*5):
Function fact(i as integer) as long
If i = 0 then
fact = 1
else
fact = i*fact(i-1)
end if
end function
Of course you can achieve this without recursion but this way its
'easier' to read.

you may have a look at the following site:
http://cse.unl.edu/~dsadofs/Recursio...p?s=algorithms
for more information (or just do a google search for 'recursive
algorithms')

HTH
Frank



David wrote:
Can anyone tell me the use of calling a sub inside itself.... please
Just some exemple to understand the uses
Thx for your help!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
General question Rookie User[_2_] Excel Worksheet Functions 2 February 8th 10 07:34 PM
A VERY General question Bons Excel Worksheet Functions 2 November 3rd 08 06:58 PM
General Question Ken Excel Discussion (Misc queries) 0 May 1st 08 05:48 PM
General Question Me Excel Discussion (Misc queries) 3 January 12th 06 12:55 PM
General Question Squid[_2_] Excel Programming 3 January 12th 04 07:25 PM


All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"