Kardi Teknomo
Kardi Teknomo Kardi Teknomo Kardi Teknomo
   
 
  Research
  Publications
  Tutorials
  Resume
  Personal
  Contact

 

Recursive Procedure

By Kardi Teknomo, PhD.

<VB Tutorial | Contents | Previous | Next >

Recursion is the ability of a routine to call itself. VB procedures (Sub and Function) can do recursive itself by calling its own name. It is also called nested procedures. Recursive procedure is very powerful way but quite difficult to debug.


1. Open a new project and type the following codes

Sub MyRecursive()
       Dim intX As Integer
       intX = intX + 1
       Call MyRecursive
End Sub
Private Sub Form_Click()
       MyRecursive
End Sub
                    

2. Run the program and see what happen
3. Try to debug the value of intX
4. Use menu: View-Call Stack to debug the procedure call

Some algorithm is recursive by nature (e.g. Dynamic Programming) and some algorithm can be translated from Recursive procedure to Repetition (using For-Next or Do-While-Loop). To define a good recursive procedure, you need to set the based value and code to get out of the recursion.

<VB Tutorial | Contents | Previous | Next >

Rate this tutorial or give your comments about this tutorial

This tutorial is copyrighted.

Preferable reference for this tutorial is

Teknomo, Kardi. Visual Basic Tutorial . http:\\people.revoledu.com\kardi\ tutorial\VB

 

 

 

 
© 2007 Kardi Teknomo. All Rights Reserved.
Designed by CNV Media