## Pi in VB6

## Pi in VB6

(OP)

I must be overlooking something obvious here, but I can't seem to use the Pi constant in VB6. What few MSDN references I can find to it aren't for VB, and several guess attempts (Pi, Pi(), Math.Pi, VbPi) all failed. So how do I use Pi in a VB calculation?

"Much that I bound, I could not free. Much that I freed returned to me."

(Lee Wilson Dodd)

## RE: Pi in VB6

i.e.

Public Const Pi As Double = 3.14159265358979

## RE: Pi in VB6

"Much that I bound, I could not free. Much that I freed returned to me."

(Lee Wilson Dodd)

## RE: Pi in VB6

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20662749.html

which certainly suggests that no such constant is supported.

## RE: Pi in VB6

"Much that I bound, I could not free. Much that I freed returned to me."

(Lee Wilson Dodd)

## RE: Pi in VB6

How can PI be a constant?

## RE: Pi in VB6

"Much that I bound, I could not free. Much that I freed returned to me."

(Lee Wilson Dodd)

## RE: Pi in VB6

"Much that I bound, I could not free. Much that I freed returned to me."

(Lee Wilson Dodd)

## RE: Pi in VB6

This is how Pi is determined:

Function PI() As Double

PI = 4# * Atn(1#)

End Function

## RE: Pi in VB6

<How can PI be a constant?> Are you suggesting there are alternative values available?

(I believe that one of the southern states passed a statute defing Pi as 3 to make maths easier but......)

________________________________________________________________

If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'

## RE: Pi in VB6

Mark

"You guys pair up in groups of three, then line up in a circle."

- Bill Peterson, a Florida State football coach

## RE: Pi in VB6

"You guys pair up in groups of PI..."?

harebrain

## RE: Pi in VB6

>How can PI be a constant?

Maybe I should have said:

How can

goodPI be a constant?Oh, Oh. I think I've mentioned before how bad my english spelling is...and, no, I'm not from that state.

Anyways, just for fun, check this out:

Const ConPI As Double = 3.14159265358979

Debug.Print CBool(CPI = (4# * Atn(1#)))

## RE: Pi in VB6

Debug.Print CBool(

ConPI= (4# * Atn(1#)))## RE: Pi in VB6

"Much that I bound, I could not free. Much that I freed returned to me."

(Lee Wilson Dodd)

## RE: Pi in VB6

Yep. Or similar.

Simply put: It depends how many decimal places PI is stored as OR, if it is dynamically calculated, how many decimal places the number type is able to calculate to, which is NOT the same as how many decimal places are actually displayed.

Try this (using the function I supplied)

?PI - 3.14159265358979#

## RE: Pi in VB6

Irrational numbers like pi and e (base of natural logarithm) theoretically cannot be expressed exactly. What we can do is only express them approximately. That's why 3, 22/7, 3.1415927 and 3.14159265358979, all are only approximations to pi but none of them exactly equals pi.

During high schools I deviced a method of representing these irrational numbers in the form of a simple fraction (i.e. in the form of Numerator/Denominator) with variably increasing accuracies.

Here are a few of such fractions approximating the value of pi in order of increasing complexity and accuracy.

reference value of pi accurate upto 15

significant figures = 3.14159265358979

--------------------------------------

simple fraction decimal value

--------------------------------------

3/1 3.00000000000000

22/7 3.14285714285714

355/113 3.14159292035398

104348/33215 3.14159265392142

312689/99532 3.14159265361894

1146408/364913 3.14159265359140

...

and so on...

The digits represented in blue indicate those which match/coincide with the reference value of pi and those in red indicate those which do not.

All of these fractions are calculated progressively with a complex method which, I'm afraid, will be difficult for me to explain here.

Note that accuracy of these fractions improves after each iteration.

Further fractions with higher accuracies can also be calculated and those would be obviously more complex.

This method can be used to approximate other irrational numbers as well --- for instance; e, the sqare root of 2 and log(50).

Any comments on this stuff are welcome...