Results 1 to 6 of 6

Thread: what's the difference between a sub and a function?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Hod Hasharon, Israel
    Posts
    109

    Arrow what's the difference between a sub and a function?

    what the diffrence between when you write a sub and you write
    a function? and what's the difference between if you use "Declare"
    to write a function?
    [Etc. Private Sub 1234()
    and
    Private Function 1234()]
    "Don't imitate, Innovate!"

  2. #2
    Matthew Gates
    Guest
    Take a look at this thread.

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736

  4. #4
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    A Sub (Sub-Rountine) contains a set of procedures that perform an action without returning a Value.
    A Function is as above, but returns a value

    e.g.
    [Code]Public Function MySum(iAddMe as Integer) as Integer

    MySum = iAddMe + 100

    Exit Function

    This can be called from another function or sub like so:

    iTotal = MySum(iTotal) (which adds 100 to iTotal)

    Declare Function is used when using function from external libraries like dlls. See www.vbapi.com for deatils...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Hod Hasharon, Israel
    Posts
    109
    that was the dumbest i ever posted...
    i have used Sub and Functions before, i just never
    knew ho to define it...
    "Don't imitate, Innovate!"

  6. #6
    wossname
    Guest
    what the diffrence between when you write a sub and you write
    a function? and what's the difference between if you use "Declare"
    to write a function?
    [Etc. Private Sub 1234()
    and
    Private Function 1234()]
    Captain's log: Additional.
    Mr. Spock has notified me that neither Subs nor Functions can be named with a number as the first letter!

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