|
-
Sep 12th, 2000, 09:54 PM
#1
Thread Starter
Addicted Member
What is the difference with "recursive" function and "callback" function?
-
Sep 12th, 2000, 11:55 PM
#2
A recursive function is one that calls itself eg:
Code:
Public Function foo(arg as Variant)
'do some stuff (like the exit case)
foo(arg)
Next Function
It has no reference point ot the function that called it.
On the other hand a call back function knows which function called it, and can talk back to that function (its a bit of a theoretical concept, and I can't provde a decnt sample)
- gaffa
-
Sep 13th, 2000, 02:38 AM
#3
Just like gaffa said a recursive function calls itself. The most usual example is a function that count the faculty of a number:
Code:
Public Function Faculty(Number As Integer) As Long
'The facutly of 1 or 0 is 1
'so that's the exit point
If Number = 1 Or Number = 0 Then
Faculty = 1
Exit Function
End If
Faculty = Number * Faculty(Number - 1)
End Function
A call back function is when you pass a pointer to a function as an argument to an other function.
The function you call in turn calls the function you pass as an argument.
A lot of API functions use callback functions. A few of them is:[*]EnumWindows[*]EnumChildWindows[*]EnumTimeFormats[*]EnumClipboardFormats[*]...and so on...
Before VB5 you couldn't use any of these functions because VB didn't have a way for passing a function pointer.
But Microsoft introduced the AddressOf keyword in VB5.
Best regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|