How to convert an object into a double?
- by george t.
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.