Results 1 to 4 of 4

Thread: Converting string to formula

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2001
    Location
    Slovenia
    Posts
    16

    Unhappy Converting string to formula

    I have a TextBox where I enter a math formula, such as X^2-3*X+2. I can save that to a string variable, then manipulate it as I need to. However, I eventually need to evaluate the mathematical result of the string. For example, if in my program, I chose X to equal 4, then I would want the string formula to somehow be evaluated to equal 6. How do I convert a string representation of a formula into the numerical result of the imbedded computation?

    I want that it calculates with what is in TextBox - variables

    Thank you

  2. #2
    Alain
    Guest

    Hmm...

    For replacing variables by values ("X" by "4", for example), you can use the simple "Replace" string function.

    But your problem gets more complicated when you want for the computer to calculate the string.... Actually, I don't think it's possible without having to write your own interpreter (that means major SELECT CASE statement, not to mention parenteses processs....wow!)

    Maybe you should look into SQL; I know it is not database related, but it seems SQL has some math functions (at least I think...). Since SQL "reads" string values, that might do what you want...

    I've attached some SQL Tutorials (I haven't read them myself yet...)

    Good luck!

  3. #3
    Alain
    Guest

    Hi guess the attach files didn't follow...

    second try!
    Attached Files Attached Files

  4. #4
    Alain
    Guest
    And again....
    Attached Files Attached Files

Posting Permissions

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



Click Here to Expand Forum to Full Width