jmasterx
jmasterx

Reputation: 54123

equation string in vb .net

I'm trying to build a scientific calculator with vb .net, except it is vista glass :-p

I basically want the user to be able to enter an equation like SQRT(5 * 6) / (2 ^ 4) and then I want vb to use system.math to solve it. If I write this in my code, vb is able to do it, so how could I do this at runtime.

Thanks

Upvotes: 1

Views: 2865

Answers (4)

xpda
xpda

Reputation: 15813

There is not a simple way to do this. You can write a parser to handle the general expressions and functions (the most fun), or you can make a call to excel or an equivalent program that handles expressions.

Upvotes: 0

MarkJ
MarkJ

Reputation: 30398

Microsoft have already done this (in Windows 7).

Scientific mode calculator in Windows 7 http://cache.gawker.com/assets/images/17/2009/07/340x_c-scientificmode.png

(I realize you're just doing this for fun and probably don't care.)

Upvotes: 0

Keltex
Keltex

Reputation: 26426

Somebody's already done this (including source code):

http://community.bartdesmet.net/blogs/bart/archive/2006/10/11/4513.aspx

Upvotes: 1

JoshJordan
JoshJordan

Reputation: 12975

Take a look at this tutorial on dynamically executing code.

Upvotes: 1

Related Questions