Function
The Function statement allows you to declare a function
that takes a variabe number of arguments and returns a value to
the caller after performing some work.
A function is identical to a subroutine except that the subroutine
is not allowed to return a value whereas a function is expected to
return a value.
' calculate how many hours old a person is
Function HoursOld(dBirthday) HoursOld = DateDiff("h", Now(), dBirthday) End Function
You may also use the Exit Function within a function to
immediately exit the function based on a condition. An example
of this is shown below:
' calculate how many hours old a person is
Function HoursOld(dBirthday) If Not IsDate(dBirthday) Then Exit Function HoursOld = DateDiff("h", Now(), dBirthday) End Function
|
 |

|