Reputation: 25
I am having a bit of trouble with the return function on VBA and was hoping someone would be able to help me troubleshoot the issue.
Here is the function:
Function Hypotenuse(side1 As Double, side2 As Double) As Double
Return Math.Sqrt((side1 ^ 2) + (side2 ^ 2))
End Function
Summary of the Issue:
Any idea why this may be happening?
Any help will be much appreciated :)
Upvotes: 0
Views: 42
Reputation: 9568
Use Sqr function .. and no Return keyword in VBA
Sub Test()
Debug.Print Hypotenuse(5, 3)
End Sub
Function Hypotenuse(side1 As Double, side2 As Double) As Double
Hypotenuse = Sqr((side1 ^ 2) + (side2 ^ 2))
End Function
Upvotes: 1