Ibra22
Ibra22

Reputation: 25

Support with the Return Function

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 :)

enter image description here

Upvotes: 0

Views: 42

Answers (1)

YasserKhalil
YasserKhalil

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

Related Questions