Ally
Ally

Reputation: 843

Compilr error: expected end of statement

I am a newbie in programming. I was doing practise on some VB code but i got that error mentioned on the subject.

Here are the codes

Function hypotenuse(ByVal a As Single, ByVal b As Single) As Single
Return Math.Sqrt((a ^ 2 ) + (b ^ 2))
End function

The error is highlighted at the return expression "Math".

Upvotes: 0

Views: 52

Answers (1)

Jeandey Boris
Jeandey Boris

Reputation: 743

In VB6/VBA, return value variable name of a function is the function name itself.

Function hypotenuse(ByVal a As Single, ByVal b As Single) As Single
    hypotenuse = Math.Sqr((a ^ 2) + (b ^ 2))
End Function

Upvotes: 2

Related Questions