0

I'm developing an app in which there's hundreds of different calculations involved and would like for my app's admins to be able to tweak these calculations by specifying the formulas.

For example, my database table contains price and quantity. One of the columns 'X' might contain "(price * quantity) over the past 7 days". How can I allow my app's admins to change the calculation from "7 days" to "14 days"?

Is there some way to make calculations dynamic within VB.NET or do I have to rely on stored procedures and write some code to alter those procedure if a change is needed? What are the best practices in this type of a scenario?

Ideally, I would like to use something similar to the "Tags" box used when posting questions on here to bring up the available fields and add mathematical operators in between them to perform calculations. It might be adding more complexity, but would be great if an existing calculation isn't overwritten so that it could be used in building a new formula.

Any help would be much appreciated. Thanks!

2 Answers 2

1

You could use an eval function, like the one described here or here.

Make sure you implement it in a way that is safe. Allowing users to execute arbitrary code can be dangerous, for obvious reasons.

Sign up to request clarification or add additional context in comments.

Comments

0

Windows Workflow has a nice "Rules" feature which is an XML based rule definitions

http://msdn.microsoft.com/en-us/library/aa480193.aspx http://stackoverflow.com/questions/1017056/parse-and-execute-formulas-with-c-sharp

You could utilise it. Alternatively you could build your own XML based formula engine. Similar to this one:

http://www.codeproject.com/Articles/25578/Dynamic-Formula-Processing-Library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.