Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
headly
 
Posts: n/a
Default Simple function problem

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
  #2   Report Post  
Trevor Shuttleworth
 
Posts: n/a
Default

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


"headly" wrote in message
...
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



  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default

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

--
HTH

Bob Phillips

"Trevor Shuttleworth" wrote in message
...
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


"headly" wrote in message
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FV Function Problem TerryG Excel Worksheet Functions 3 June 13th 05 09:26 PM
Function formula for simple worksheet mouse New Users to Excel 1 June 9th 05 03:00 PM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM
Simple, Monday morning brain function craigwojo Excel Worksheet Functions 1 November 16th 04 03:07 AM
Simple, Monday morning brain function craigwojo Excel Worksheet Functions 2 November 15th 04 01:43 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"