Simple function problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Maybe I'm too tired to see the obvious, could somebody explain why this
simple function is producing 0 instead of a result?

Public Function AreaCircle(Radius) As Double
Const conPi As Single = 3.141592
AreaofCircle = conPi * (Radius ^ 2)
End Function

If I run it as a sub procedure it works fine.

TIA
 
Try:

Public Function AreaofCircle(Radius) As Double
Const conPi As Single = 3.141592
AreaofCircle = conPi * (Radius ^ 2)
End Function

or

Public Function AreaCircle(Radius) As Double
Const conPi As Single = 3.141592
AreaCircle = conPi * (Radius ^ 2)
End Function

Depending on your preference - the function name is different to the
variable

Regards

Trevor
 
If you used Option Explicit, this would have been obvious to you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top