I am going to try my best to explain how parameters are used in subroutines and in functions,Here goes...to my understanding:)
Parameters are the inputs required for a behaviour to execute/work/run
In order to accomplish a task on some occasions further input or information is needed and thats where parameters come into play
In the case of subroutines let me use this example:
Public Sub Login(Username as string,Password as string)
In the above example there are two parameters needed in order to execute the behaviour which in this case is loging in,in order to do this we need our username and password otherwise we cant log in
Keeping in mind that a subroutine executes code but does not return a value
In the case of functions let me use this example:
Public Function Calculate(NumberOne as integer,NumberTwo as integer)As integer
In the above example there are also two parameters needed in order to execute the behaviour which in this case is the calculation of number one and the calculation of number two
In these examples we see that yes sometimes more then one parameter is needed in order to execute a code
Since a function returns a value the result of the parameters will be returned as an integer because as you can see above we asked for an interger value to be returned
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment