none
Procedures and Functions

Answers

  • Functions and Sub

    Function return a single value

    ie. 

    Function Foo () as string

    End Function

     

    Sub dont return a value

    Sub Bar

    End Sub

     

    Saying that you can make a parameter on a sub return a value by passing it as a references using byref rather than byval which allows the sub / function to modify the contents of the variable in the calling function

     

    Which to use ?   It depends upon you circumstances as to whether you want to return multiple values from a method.   If you only want to return a single datatype (it could be a single datatype containing multiple values such as an arraylist) then a function may be suitable.   If you want to return multiple datatype values from the same method call you may need to use a sub and pass the variables byref.

     

    Wednesday, October 11, 2006 3:05 AM

All replies

  • Functions and Sub

    Function return a single value

    ie. 

    Function Foo () as string

    End Function

     

    Sub dont return a value

    Sub Bar

    End Sub

     

    Saying that you can make a parameter on a sub return a value by passing it as a references using byref rather than byval which allows the sub / function to modify the contents of the variable in the calling function

     

    Which to use ?   It depends upon you circumstances as to whether you want to return multiple values from a method.   If you only want to return a single datatype (it could be a single datatype containing multiple values such as an arraylist) then a function may be suitable.   If you want to return multiple datatype values from the same method call you may need to use a sub and pass the variables byref.

     

    Wednesday, October 11, 2006 3:05 AM
  • gee, thanks alot.
    Wednesday, October 11, 2006 3:25 AM