## Lesson 1.2 homework solution

You need to be logged in to view this content. Please login or become a member.

1. Joe_Limon

dblVolume = (4 / 3) * intRadius ^ 3

should be

dblVolume = (4 / 3) *dblPi* intRadius ^ 3

• Keith

Oops. :) Thanks for pointing that out Joe!

2. Slurry_Pumper

I attempted to enter the more accurate version for pie with the declarative variables and use a constant command. The program didn’t enjoy my antics very much, so can I conclude that there are to be no formulas in the variable declaration sections? Even if the answer is a constant?

• Keith

If your constant declaration contains any variables then VBA will throw a compile error. If you want pi controlled as a constant, your options are:

1. Create a constant with pi out to many digits, like this:

`Const PI As Double = 3.14159265358979`

2. Create a string constant containing 4 * Atn(1) (which will calculate the value of pi) and then evaluate it in your code, like this:

```Const PI_EQN As String = "4 * Atn(1)" Sub main()     Debug.Print Evaluate(PI_EQN, True, True) End Sub```