Notă
Accesul la această pagină necesită autorizare. Puteți încerca să vă conectați sau să modificați directoarele.
Accesul la această pagină necesită autorizare. Puteți încerca să modificați directoarele.
You use a Function procedure to return a value to the calling code.
To create a procedure that returns a value
Outside any other procedure, use a
Functionstatement, followed by anEnd Functionstatement.In the
Functionstatement, follow theFunctionkeyword with the name of the procedure, and then the parameter list in parentheses.Follow the parentheses with an
Asclause to specify the data type of the returned value.Place the procedure's code statements between the
FunctionandEnd Functionstatements.Use a
Returnstatement to return the value to the calling code.The following
Functionprocedure calculates the longest side, or hypotenuse, of a right triangle, given the values for the other two sides.Function Hypotenuse(side1 As Double, side2 As Double) As Double Return Math.Sqrt((side1 ^ 2) + (side2 ^ 2)) End FunctionThe following example shows a typical call to
hypotenuse.Dim testLength, testHypotenuse As Double testHypotenuse = Hypotenuse(testLength, 10.7)