PDA

Click to See Complete Forum and Search --> : Diference between Sub and Function


BShadow
May 14th, 2002, 06:37 AM
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?

Si_the_geek
May 14th, 2002, 07:28 AM
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:


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