Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Let the user write a line code

Let the user write a line code

Scheduled Pinned Locked Moved C#
questiongame-dev
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bonzaiholding
    wrote on last edited by
    #1

    I have a class with a scientific members in physics. I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".) How can i do it?

    N D S P 4 Replies Last reply
    0
    • B bonzaiholding

      I have a class with a scientific members in physics. I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".) How can i do it?

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      Have a look at Inside the Mathematical Expressions Evaluator[^].

      bonzaiholding wrote:

      I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".)

      You can search the input string for the variables ("x1", "x2", ...) and replace them with their corresponding values from your properties. After that, you can pass the string to the Mathematical Expressions Evaluator and get the result. :)

      Nuri Ismail

      B 1 Reply Last reply
      0
      • B bonzaiholding

        I have a class with a scientific members in physics. I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".) How can i do it?

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        You are looking for a Math parser. You can find lot of related help on google.

        It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

        1 Reply Last reply
        0
        • N Nuri Ismail

          Have a look at Inside the Mathematical Expressions Evaluator[^].

          bonzaiholding wrote:

          I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".)

          You can search the input string for the variables ("x1", "x2", ...) and replace them with their corresponding values from your properties. After that, you can pass the string to the Mathematical Expressions Evaluator and get the result. :)

          Nuri Ismail

          B Offline
          B Offline
          bonzaiholding
          wrote on last edited by
          #4

          Thanks for all of your answers.

          1 Reply Last reply
          0
          • B bonzaiholding

            I have a class with a scientific members in physics. I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".) How can i do it?

            S Offline
            S Offline
            Senseicads
            wrote on last edited by
            #5

            Sigh, I remember having to do this at uni....RPN anyone? Seriously though look up Reverse Polish Notation and stacks. It might help...it might not :) I am not very helpful am I? I just went on a nostalgia trip is all because of your post! :) thank you :) Cads

            1 Reply Last reply
            0
            • B bonzaiholding

              I have a class with a scientific members in physics. I want to let the user to enter a text in a textbox like "x1+x2*3+x3/4" and i want to calc this values in run-time. (Lets say that i have properties that called "x1", "x2" and "x3".) How can i do it?

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              RPN[^]

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups