|
-
May 14th, 2002, 06:37 AM
#1
Thread Starter
Hyperactive Member
Diference between Sub and Function
Hello people,
I was wondering, what is the diference between an sub and a function? Other than the fact that the function itself can be returned as a variable.
When creating Class modules and normal Modules, what is the reason for using a sub and for using a function?
"Experience is something you don't get until just after you need it."
-
May 14th, 2002, 07:28 AM
#2
You have basically answered your own question, the fact that a function returns a value is the only difference.
You only need to use a function if for some reason you want it to return a value, eg:
VB Code:
Function Min(ByVal valueA, ByVal valueB)
'Returns minimum of two values, or nothing if incompatible types
'(first value if equal)
On Error Resume Next
Min = IIf(valueB < valueA, valueB, valueA)
End Function
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
|