Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VB Equation solver.

RelmanRelman Posts: 104Member
I've been writing a calculator that shows all the steps in working out a sum. I've currently done showing the working out for "+", "-", "*" and "/". To do that I needed to get a parser to parse an equation (Ie. if I got 5+3+5+6*5+3*5/3" It would work through the sum giving me numbers I could deal with for showing the working out). Having done that, I want to add the ability to solve equations like "5X-2X^2+5-3=7X". In order to do that, I need an idea as to how to make such a parser (Even source code...). I tried one idea - I took out "X" with its Index and its exponent on the side containing "X" and sent the sum whch didn't contain "X" into the parser to return me a number and then "-"ssed "X" from it (Or "+"ssed, depending on the sum) and it returned me the answer. The problem with this was that I only managed to work out code to take out ONE "X" with its exponents.

If you have code, an idea or anything, pls reply.

Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    : I've been writing a calculator that shows all the steps in working out a sum. I've currently done showing the working out for "+", "-", "*" and "/". To do that I needed to get a parser to parse an equation (Ie. if I got 5+3+5+6*5+3*5/3" It would work through the sum giving me numbers I could deal with for showing the working out). Having done that, I want to add the ability to solve equations like "5X-2X^2+5-3=7X". In order to do that, I need an idea as to how to make such a parser (Even source code...). I tried one idea - I took out "X" with its Index and its exponent on the side containing "X" and sent the sum whch didn't contain "X" into the parser to return me a number and then "-"ssed "X" from it (Or "+"ssed, depending on the sum) and it returned me the answer. The problem with this was that I only managed to work out code to take out ONE "X" with its exponents.
    :
    : If you have code, an idea or anything, pls reply.
    :

    Look into using regular expressions. The book "Programming Microsoft Visual Basic.NET" By Franscesco Balena has an actual equation parser in the Regular Expressions chapter. It will handle an equation such as ...

    2X^2+5-3=7X

    Accept maybe the "^" operator which can be easily added. The code is too long to list right now.


  • RelmanRelman Posts: 104Member
    : : I've been writing a calculator that shows all the steps in working out a sum. I've currently done showing the working out for "+", "-", "*" and "/". To do that I needed to get a parser to parse an equation (Ie. if I got 5+3+5+6*5+3*5/3" It would work through the sum giving me numbers I could deal with for showing the working out). Having done that, I want to add the ability to solve equations like "5X-2X^2+5-3=7X". In order to do that, I need an idea as to how to make such a parser (Even source code...). I tried one idea - I took out "X" with its Index and its exponent on the side containing "X" and sent the sum whch didn't contain "X" into the parser to return me a number and then "-"ssed "X" from it (Or "+"ssed, depending on the sum) and it returned me the answer. The problem with this was that I only managed to work out code to take out ONE "X" with its exponents.
    : :
    : : If you have code, an idea or anything, pls reply.
    : :
    :
    : Look into using regular expressions. The book "Programming Microsoft Visual Basic.NET" By Franscesco Balena has an actual equation parser in the Regular Expressions chapter. It will handle an equation such as ...
    :
    : 2X^2+5-3=7X
    :
    : Accept maybe the "^" operator which can be easily added. The code is too long to list right now.
    :
    :
    :
    Thanks for both your replies,

    Relman
Sign In or Register to comment.