Re: Pi in VBA?

  • Thread starter Thread starter Rick Rothstein
  • Start date Start date
R

Rick Rothstein

You could just assign the value to a constant directly...

Const PI = 3.14159265358979

Or you can let VB calculate it for you...

PI = 4 * ATN(1)
 
Rick Rothstein said:
You could just assign the value to a constant directly...
Const PI = 3.14159265358979

Or you can let VB calculate it for you...
PI = 4 * ATN(1)

Your constant for PI does not equal VB 4*Atn(1) or Excel PI().

However, if you enter the constant as 3.141592653589793, that does result in
the same binary value as 4*Atn(1) and PI(), even though VB will not display
the last 3.
 
Hi. Just to be a little different...
Not really recommended, but a poor-man's version of the Pi symbol can
sometimes be done via the Paragraph symbol. You have to have a little
imagination thou to see it as Pi :>)

Sub Demo()
Dim c
Dim ¶ 'Alt + 0182

¶ = [Pi()]

c = 2 * ¶ * 5
End Sub

Dana DeLouis
= = = =
 
Thank you.

Wrapping in [ ] instead of Application.WorksheetFunction is new
information for me. Hopefully, the memory banks will retain this gem.

--
Steve

Dana DeLouis said:
Hi. Just to be a little different...
Not really recommended, but a poor-man's version of the Pi symbol can
sometimes be done via the Paragraph symbol. You have to have a little
imagination thou to see it as Pi :>)

Sub Demo()
Dim c
Dim ¶ 'Alt + 0182

¶ = [Pi()]

c = 2 * ¶ * 5
End Sub

Dana DeLouis
= = = =

Prof said:
This is why I don't want to hard code a trancendental constant.
 
------snip------
Sub Demo()
Dim c
Dim ¶ 'Alt + 0182

¶ = [Pi()]

c = 2 * ¶ * 5
End Sub
------snip------

That is SO neat!

The poor sods who inherit my code are going to be scratching their
heads at all the weird variable symbols that are going to be cropping
up. <vbg>

Nick H
 
Back
Top