If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel option to store trendline's coefficients in cells for use | Miguel Saldana | Charts and Charting | 9 | June 20th, 2005 08:45 PM |
Problem with Excel SUM function | JoeD | Worksheet Functions | 7 | June 8th, 2005 04:19 PM |
Match Function Problem - Won't Find Certain Numbers | PE | General Discussion | 2 | May 9th, 2005 03:53 PM |
Function problem | Miles | General Discussion | 1 | January 20th, 2005 11:06 PM |
Match function problem | Tom | Worksheet Functions | 0 | September 22nd, 2003 09:05 PM |