Home All Groups Group Topic Archive Search About

Excel type calculation

Author
11 Jan 2006 2:32 PM
Paul Remblance
Is there a 'simple' way to perform a calculation on a textbox entry similar
to Excel. For example: if the user enters =2*3 the validated event changes
it to 6.

Author
11 Jan 2006 2:36 PM
Larry Lard
Paul Remblance wrote:
> Is there a 'simple' way to perform a calculation on a textbox entry similar
> to Excel. For example: if the user enters =2*3 the validated event changes
> it to 6.

In the old days this would have meant lexing the input, building a
parse tree, and walking that to produce a result. These days, we have
the (to my mind extremely elegant) method of using regexes to do all
the work. See for example

<http://www.devx.com/vb2themax/Tip/19438>

or just google for regex expression evaluator.

--
Larry Lard
Replies to group please
Author
11 Jan 2006 3:21 PM
Paul Remblance
Show quote Hide quote
> Paul Remblance wrote:
>> Is there a 'simple' way to perform a calculation on a textbox entry
>> similar
>> to Excel. For example: if the user enters =2*3 the validated event
>> changes
>> it to 6.
>
> In the old days this would have meant lexing the input, building a
> parse tree, and walking that to produce a result. These days, we have
> the (to my mind extremely elegant) method of using regexes to do all
> the work. See for example
>
> <http://www.devx.com/vb2themax/Tip/19438>
>
> or just google for regex expression evaluator.

Not what I would call 'simple' but it works fine, many thanks.