Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


In addition to the above types, the return type can be:

  • Void


Parameters Each parameter can have default values and expressions.a default value, which is used if the parameter is not included in the call.  The default parameter is declared by following the parameter name with an equal sign and the default value.  If any parameter has a default value, then each following parameter must also have a default value.  In the following examples, the functions add2 and add3 can be called with either one or two parameters.

Code Block
languagevb
titleExample
Function cat(a, b)
	Return a+b 'a, b could be numbers or strings
End Function 

Function five() as Integer
	Return 5
End function 
 
Function add(a as Integer, b as Integer) As Integer
	Return a+b
End function 


Function add2(a as Integer, b=5 as Integer) As Integer
	Return a+b
End Function 


Function add3(a as Integer, b=a+5 as Integer) as Integer
	Return a+b
End Function

...