A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Simple function problem



 
 
Thread Tools Display Modes
  #1  
Old July 7th, 2005, 05:27 AM
headly
external usenet poster
 
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  
Old July 7th, 2005, 06:44 AM
Trevor Shuttleworth
external usenet poster
 
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  
Old July 7th, 2005, 08:50 AM
Bob Phillips
external usenet poster
 
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





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 09:42 PM.


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