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?

Joe_LimondblVolume = (4 / 3) * intRadius ^ 3

should be

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

KeithOops. :) Thanks for pointing that out Joe!

Slurry_PumperI 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?

KeithIf 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