geonaf Posted January 30, 2003 Posted January 30, 2003 Is the following possible in vb net?: The user types in a mathematical expression for X and the program calculates it for x=1,eg: Input: x^2+E^x Output: 3.71828 Please help me!!! Quote
*Experts* Volte Posted January 30, 2003 *Experts* Posted January 30, 2003 I don't believe there is any easy, built in way (I could be wrong). I looked into possibly using the Debug window to evaluate expressions, but I couldn't see any way to do it by code. However, it may be worth further investigation. You could look online for an expression evaluator, or search the MSDN to see if I am indeed incorrent; there could be a built in one, I'm not sure. Quote
Moderators Robby Posted January 30, 2003 Moderators Posted January 30, 2003 It is possible. You will need to parse the entire string looking for any operator and all the numbers which surround them. Perhaps place them into an array from a Regular Expression (split) Quote Visit...Bassic Software
Moderators Robby Posted January 30, 2003 Moderators Posted January 30, 2003 If you decide to go with RegEx, Wyrd has a tutorial on it here, http://www.xtremedotnettalk.com/showthread.php?s=&threadid=49579 I would try and use SubString to start. Quote Visit...Bassic Software
*Gurus* divil Posted January 30, 2003 *Gurus* Posted January 30, 2003 As a side note, the immediate window can handle equations like that I think. [edit]Perhaps not.[/edit] Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.