Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert String to Formula (XP SP3)

    Hello everybody,

    I am facing a new problem, from which I do not know whether there is a ready made solution already, or if I have to do it on my own. So here it is: Imagine you have a userform with a textfield where the user may enter an equation (e.g. "=0.5*(x-2)^2+2*x-3"). Naturally, I can access this equation as a text string and store it in a variable. I now need to find a way to convert it into an equation I can work with in my code. I know that I could use the Evaluate-command to get this solved for such relatively simple examples. Unfortunately, the formula can become much more complex, including a higher number of variables than only "x". I somehow need to find out what are the variables and how they are linked together. Has someone done s.th. like this before? Is there a built in function I yet did not recognize?
    Any comments on this would be highly appreciated. It would also be very helpful if someone had a source where to find more information about this.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert String to Formula (XP SP3)

    See Software Download for free add-ins, among which a 'Class Math Expression Parser' and a 'Fast Formula Evaluator for EXCEL'.

    Alternatively, try the free Power Calculator from Microsoft (Microsoft PowerToys for Windows XP). It can evaluate symbolic expressions.

    Or get Maple or Mathematica

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert String to Formula (XP SP3)

    Hello Hans,

    thank you for the resources. It seems that the Math Expression Parser could be used (though it seems to handle more than I need ;-)). Unfortunately, the given alternatives aren't really ones, since I am bound to Excel for this task.
    So thanks again!

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert String to Formula (XP SP3)

    In that case, your alternative seems to be to write VBA code to parse the expression yourself. That is going to be a very complex undertaking. I would suggest that you start by finding a book/atricle on "Reverse Polish Notation". Wikipedia might be a good start.
    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •