WordBasic Error Using Caret for Exponentiation in Math FormulaLast reviewed: July 30, 1997Article ID: Q87717 |
The information in this article applies to:
SUMMARYIf 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 MORE INFORMATIONPage 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^2If 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 STATUSThis problem was corrected in Word 97.
WORKAROUNDTo 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 SubThe 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 REFERENCES"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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |