ID: Q87717
The information in this article applies to:
If you use the caret character (^) to perform exponentiation in a Microsoft Word for Windows macro, the following error message is generated:
WordBasic Err=100
Syntax error
Page 31 of the "Using WordBasic" manual, written by WexTech Systems and Microsoft, documents exponentiation in mathematical formulas using the caret character within a WordBasic macro.
The example shown is as follows:
CircleArea = pi*r^2
If you run a macro that contains this line, the WordBasic syntax error
occurs. There is no supported mathematical operator in WordBASIC for
exponential calculations.
For information , please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q74050
TITLE : Supported Mathematical Operators in WordBasic
This problem was corrected in Word 97.
To perform a mathematical calculation that involves exponents, you can use the ToolsCalculate() function. This functions returns a value to a numeric variable. For example, to find the value of two to the eighth power (2^8), use the following WordBASIC statement:
x=ToolsCalculate("2^8")
-or-
Sub MAIN
pi = 3.14159
x = ToolsCalculate("2^2")
CircleArea = pi * x
Print circlearea
End Sub
The ToolsCalculate method does not accept variable names such as power and
base. For example, the following macro results in a WordBasic bad parameter
error:
power = 8
base = 2
x = ToolsCalculate("base^power")
The following macro example performs the sample calculation using
variables:
Sub MAIN
power = 8
base = 2
result = 1
For count = 1 To power
result = result * base
Next
Print result
End Sub
"Using WordBasic," by WexTech Systems and Microsoft, page 31
"Microsoft Word Developer's Tools Forum," page 113 (from the Macro Developers Kit)
Kbcategory: kbusage kbmacro KBSubcategory: Additional query words: 2.0 2.0a 2.0a-CD 2.0b winword word6 winword 7.0 word95 word7 docerr doc err exponent exponentiate power calculate mdk winword2 6.0 ToolsCalculate
Version : 2.x 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS
Last Reviewed: July 30, 1997