Question user formula inputed?

tselie115

Registered User.
Local time
Yesterday, 16:11
Joined
Aug 10, 2008
Messages
44
hey guys hope i ll get help from you experts because im not able to solve this.
i want to build a form that will allow the user to set his own mathematical fomula, name it and save it.
when needed, the user will chose ,from a combo box ,the name of the formula he set before and the result will be based on this formula.

to make it clearer.
if the user have variables A, B and C and Z as result.
suppose he set up the formula

alpha= 2A+B-C
beta=3a*B/C

in the combo box, if he choses alpha from the list, the result should be based on the formula he set up.
if A =2 B=1 and C=1
when chosin alpha from combo box
Z will be calculated as
2*2+1-1
2*A+B-C

i hope i am clear.
thank you for ur help again.
 
??

is it impossible? why nobody isnt answering? isnt it clear?
 
It's Sunday morning. Remain calm.
 
Good morning -

Simple Example:

1) Create a new form

2) Add three text boxes and rename them txtA, txtB, txtC. Added: Set their default values = 0, which may prevent errors if you fail to provide a value.

3) Add a combo box named cboFormula. Set it to 2 columns, bound column = 1, column widths = 0";1". Set Row Source Type to Value List; Copy/paste this to the Row Source: 1;Alpha: 2A + B - C;2;Beta: 3A * (B / C).

4) Add a fourth text box name txtResponse.

5) Return to cboFormula. In the After Update Event, create an event. Open the form module in the Private Sub cboFormula_AfterUpdate(), copy/paste the following, which uses the Switch() function to select and implement the desire formulas:
Me.txtResponse = Switch(Me.cboFormula = 1, 2 * Me.txtA + Me.txtB - Me.txtC, Me.cboFormula = 2, 3 * Me.txtA * (Me.txtB / Me.txtC))

What happens is that you select a formula in cboFormula. The selections are labeled (although hidden) as 1, 2 .... Once selected, the cboFormula_AfterUpdate() sub opens and, depending on your selection, implements the selected formula based on the values you've entered in txtA, txtB and txtC and displays the result in txtResponse.

Once you get that setup and working you can expand upon it by adding additional menu items to cboFormula's value list, and expanding on the Switch() function's options.

Have fun, remain calm - Bob
 
Last edited:
It's still way too early on a Sunday morning to think that hard.
 
it is perfectly working, thank you man on this sunday morning:)
sorry for bothering
 

Users who are viewing this thread

Back
Top Bottom