Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Sashanan (Programmer) (OP)
17 Sep 03 3:37
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)

Glasgow (IS/IT--Management)
17 Sep 03 3:56
Cant you just set up your own constant = 3.14159265358979

Public Const Pi As Double = 3.14159265358979

Sashanan (Programmer) (OP)
17 Sep 03 3:57
That'd work, but is Pi really just not present as a VB constant? I find that hard to believe.

"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)

Glasgow (IS/IT--Management)
17 Sep 03 4:08
I've never needed it or looked for it and certainly can't see anything in the documentation to suggest it is supported. Also, take a look at last response in:

which certainly suggests that no such constant is supported.
Sashanan (Programmer) (OP)
17 Sep 03 4:13
Certainly looks like it. Well, it's a surprise, but no worries as the Double declaration will do just fine. Thanks for the insight.

"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)

Helpful Member!  CCLINT (Programmer)
17 Sep 03 4:20

How can PI be a constant?
Sashanan (Programmer) (OP)
17 Sep 03 4:21
Simple question, very good question. Guess I didn't think this through. :)

"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)

Sashanan (Programmer) (OP)
17 Sep 03 4:23
Although...even though an accurate Pi could not be caught in a constant (mainly because an accurate Pi does not exist), I would have expected there to be a rounded one. Regular Basic (at the very least my Commodore 64's Basic interpreter as well as GWBasic and QBasic on the PC) did have it defined with 8 digit precision or something.

"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)

CCLINT (Programmer)
17 Sep 03 8:39
I was just being difficult.
This is how Pi is determined:

Function PI() As Double
    PI = 4# * Atn(1#)
End Function

johnwm (Programmer)
17 Sep 03 17:16
<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.'

MarkSweetland (MIS)
17 Sep 03 18:38
Us southerners kinda use "shade over three" as PI...


"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach

harebrain (MIS)
17 Sep 03 20:07
Then shouldn't your tag read:

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

CCLINT (Programmer)
18 Sep 03 6:44
PI = 3 <bursting>

>How can PI be a constant?
Maybe I should have said:
How can good  PI 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#)))
CCLINT (Programmer)
18 Sep 03 6:46
Opps. Should read:

Debug.Print CBool(ConPI = (4# * Atn(1#)))
Sashanan (Programmer) (OP)
22 Sep 03 2:43
Interesting...that anything like the old trick of taking out a calculator, typing in 3,141592674, then minus, then the pi button, then equals? I'd get answers like 0.1 E-14 or such.

"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)

CCLINT (Programmer)
22 Sep 03 2:58

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#

Hypetia (Programmer)
22 Sep 03 9:56
I think this thread is now complete and over covering all aspects but I just wanted to add something related to pi which might be interesting for some readers.

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...

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close