Author Topic: Evaluating Formulaes from Strings  (Read 2351 times)

0 Members and 1 Guest are viewing this topic.

hendie

  • Guest
Evaluating Formulaes from Strings
« on: October 18, 2007, 08:09:08 AM »
I have a form in which users will create a formula inside a textbox.
I need to test the formula and see that it works before I can allow the user to continue.
I am having trouble trying to evaluate the expression. It could be a complex formula or something as simple as  1+(100*2)
The only way I can see to do is is to parse the string character by character which I was hoping not to have to do. Anyone have any ideas ?

Glenn R

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #1 on: October 18, 2007, 08:12:11 AM »
Without more information as to the possibilities of the formulae entered, I would suggest a serious look at regular expressions.

Guest

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #2 on: October 18, 2007, 08:16:23 AM »
Add a reference to the Microsoft Script Control and you should be good to go... :)

http://www.a1vbcode.com/vbtip-3.asp

Glenn R

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #3 on: October 18, 2007, 08:19:58 AM »
Well, there you go...even better. Good one Matt.

Guest

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #4 on: October 18, 2007, 08:20:14 AM »
Well, there you go...even better. Good one Matt.

 :wink:

hendie

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #5 on: October 18, 2007, 08:36:33 AM »
sounds just like what I need.
thanks

hendie

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #6 on: October 18, 2007, 09:58:08 AM »
Matt, that was perfect, thanks again

Guest

  • Guest
Re: Evaluating Formulaes from Strings
« Reply #7 on: October 18, 2007, 10:08:25 AM »
You're welcome.