Results 1 to 2 of 2

Thread: Diference between Sub and Function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    425

    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."

  2. #2
    Si_the_geek
    Guest
    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:
    1. Function Min(ByVal valueA, ByVal valueB)
    2. 'Returns minimum of two values, or nothing if incompatible types
    3. '(first value if equal)
    4.  
    5.   On Error Resume Next
    6.   Min = IIf(valueB < valueA, valueB, valueA)
    7.  
    8. 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
  •  



Click Here to Expand Forum to Full Width