Calculating Equations in a Spreadsheet

Of all of the programs I’ve written for this book, I felt that the Charter program could benefit the most from using the ScriptControl. The ability to evaluate expressions in the grid part of the program could add significant value to this simple spreadsheet program. Figure 13.14 shows how I can enter an equation into a cell.

Adding this capability requires modifying many of the existing functions because of a new global variable called Equations. The Equations variable is a string array, where each element in the string array corresponds to a cell on the grid. Rather than go through every routine that was changed, I’m just going to cover those that are related to using the ScriptControl.

Figure 13.14: Entering an equation into Charter

© 1998 SYBEX Inc. All rights reserved.