View Single Post
Old 01-13-2004, 05:01 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Retired Moderator
* Guru *
Join Date: May 2001
Location: Vorlon
Posts: 19,175
Default FlexSpread Class

I created a class to extend the functionality of the MSFlexGrid with Excel like functions.

The class supports cell editing, but you can also add formula's and expressions in the cell.

Like in Excel if the text starts with a "=" then the rest of the text is parsed.

Simple cell references can be used using [] -> [row,col]

I added two range functions myself: SUM and AVG
cFlexSpread.TextFormula(4, 3) = "=sum([1,1]:[3,3])" cFlexSpread.TextFormula(4, 3) = "=avg([1,1]:[3,3])"
For all other mathematical functions I used the Eval method of the ScriptControl which can be combined with cell references.
cFlexSpread.TextFormula(4, 3) = "=[1,1] * Sin([3,3]))"

Also added 3 events:
Private Sub cFlexSpread_AfterEdit(Row As Long, Col As Long) Debug.Print "AfterEdit", Row, Col End Sub Private Sub cFlexSpread_BeforeEdit(Row As Long, Col As Long, Cancel As Boolean) Debug.Print "Before", Row, Col ' lock column 3 Cancel = (Col = 3) End Sub Private Sub cFlexSpread_EvalError(Row As Long, Col As Long) Debug.Print "EvalError", Row, Col End Sub
Attached Files
File Type: zip (5.2 KB, 613 views)

Last edited by Flyguy; 01-20-2004 at 11:32 AM.
Reply With Quote