How to convert an object into a double?

Posted by george t. on Stack Overflow See other posts from Stack Overflow or by george t.
Published on 2010-05-21T00:19:01Z Indexed on 2010/05/21 0:20 UTC
Read the original article Hit count: 647

Filed under:
|
|
|

I am working on VS C# on the following code, which converts an user input math expression and computes it.

MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl(); sc.Language = "VBScript";

        sc.ExecuteStatement(
            "function pi\n"
            + "pi = 3.14159265\n"
            + "end function");

        sc.ExecuteStatement(
            "function e\n"
            + "e = exp(1)\n"
            + "end function");

expression = textBox1.Text.ToString(); expression = expression.Replace("x", i.ToString()); object y = sc.Eval(expression);

            string k = y.ToString();
            double result = double.Parse(k);

While this outputs onto the console with the correct result, I want to use the values to make a graph of the function user inputs and it's not doing it correctly.

Thank you for your help.

© Stack Overflow or respective owner

Related posts about graph

Related posts about c#