what calculate the formula?

  • Thread starter Thread starter VladimirT
  • Start date Start date
V

VladimirT

I have TextBox in him User enters the formula for instance Cos(x) what
compute in code of the program?

she is got text ((

many thanks
 
I assume you want to do evaluation of formulas in your program. There are a
few options avbl. One is to write your own evaluation using postfix algo.
This will work fine if you have a small set of functions you want to
evaluate. The other maybe to use reflection.emit to generate code for the
expression and execute it at runtime.

Rgds,
Anand M
VB.NET MVP
http://www.dotnetindia.com
 
I have TextBox in him User enters the formula for instance Cos(x) what
compute in code of the program?

she is got text ((

many thanks


What you wrote doesn't make very much sense...

But you can go:

txtBoxValue.text = Cstr(Cos(Cint(txtCos.text)))
 
my code

Function FunctionEval(ByVal X As Double) As Double

Try

FunctionEval = Cos(X * 10)

'FunctionEval = txtFunction.Text?????? I want here to take from textbox as?

Catch exc As Exception

Console.WriteLine(exc.Message)

End Try

End Function
 
my code

Function FunctionEval(ByVal X As Double) As Double

Try

FunctionEval = Cos(X * 10)

'FunctionEval = txtFunction.Text?????? I want here to take from textbox as?
I it is necessary for ÎÁÚÎÙÈ function sin,cos,tg,ctg



Catch exc As Exception

Console.WriteLine(exc.Message)

End Try

End Function
 
Vladimir,

Still not tried by me.

\\\Eval by Nigel Amstrong
1. Create a file called: DynamicMath.js
2. Add this code to it:

class DynamicMath
{
static function Eval(MathExpression : String) : double
{
return eval(MathExpression);

};
}
3. Compile it with the command line jsc compiler: jsc /t:library
DynamicMath.js
4. Add a reference to DynamicMath.dll to your project (and to
Microsoft.JScript.dll as well)
5. Use from your favourite .NET language:
Dim d As Double = DynamicMath.Eval("2 + 3 + 4")
MessageBox.Show(d)
6. That's it..
///

I hope this helps a little bit?

Cor

VladimirT said:
Function FunctionEval(ByVal X As Double) As Double

Try

FunctionEval = Cos(X * 10)

'FunctionEval = txtFunction.Text?????? I want here to take from textbox
as?
I it is necessary for ÎÁÚÎÙÈ function sin,cos,tg,ctg



Catch exc As Exception

Console.WriteLine(exc.Message)

End Try

End Function
 
can not create dll mistake heap (((

Cor Ligthert said:
Vladimir,

Still not tried by me.

\\\Eval by Nigel Amstrong
1. Create a file called: DynamicMath.js
2. Add this code to it:

class DynamicMath
{
static function Eval(MathExpression : String) : double
{
return eval(MathExpression);

};
}
3. Compile it with the command line jsc compiler: jsc /t:library
DynamicMath.js
4. Add a reference to DynamicMath.dll to your project (and to
Microsoft.JScript.dll as well)
5. Use from your favourite .NET language:
Dim d As Double = DynamicMath.Eval("2 + 3 + 4")
MessageBox.Show(d)
6. That's it..
///

I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top