# Creating a custom formula calculator

## Recommended Posts

Hello there,

I was wondering if it's possible to create some kind of calculator with custom formulas...

I'm dutch and I often use my own letters in formula's, since I only have very basic physics almost all formulas look the same.

This is an example:

A=B*C

C=A/B

B=A/C

Now would I be able to create a calculator for this? That calculates the A if I fill in B and C?

Thanks a lot,

Chris

##### Share on other sites

Use search before posting question !

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

##### Share on other sites

I did.

I had a look at some calculators in the Example Scripts, but I didn't understand them.

That's why I posted

##### Share on other sites

The short answer to your question is:

Yes!

The long and slightly more complex answer is:

Yes, you would be able to do this if you are willing to do a bit of reading and put a bit of effort into it.

Edited by Bomi

Okay, thank you

##### Share on other sites

I am not sure what level of complexity you were looking for but I came up with this.

1. Fill in the constants with alphabet characters and their associated equation.

2. Enter the equation you want to compute using the constants you entered.

A = 1

B = 2

C = 3

Equation = A+B+C

Effective equation = 1+2+3

Result = 6

```#include <GUIConstants.au3>

GUICreate("My GUI", 400, 480)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

GuiCtrlCreateLabel("Constant", 10,10)
GuiCtrlCreateLabel("Formula", 200,10)

Dim \$array[10][2]

For \$Y = 0 to 9
\$array[\$Y][0] = GuiCtrlCreateInput("", 20,(\$Y * 25)+30,20,20)
\$array[\$Y][1] = GuiCtrlCreateInput("", 70,(\$Y * 25)+30,320,20)
Next

GuiCtrlCreateLabel("Equation", 10,300)
\$equationInput = GuiCtrlCreateInput("", 10,320,380,20)

GuiCtrlCreateLabel("Effective Equation", 10,350)
\$effectiveInput = GuiCtrlCreateInput("", 10,370,380,20)

\$answerInput = GuiCtrlCreateInput("", 10,420,380,20)

\$button = GuiCtrlCreateButton("Calculate", 170, 450, 60, 20)

; Run the GUI until the dialog is closed
While 1
\$msg = GUIGetMsg()

Switch \$msg
Case \$GUI_EVENT_CLOSE
ExitLoop
Case \$button
Calculate()
EndSwitch
Wend

Func Calculate()

For \$Y = 0 to 9

If IsString(\$constant) and StringLen(\$constant) > 0 Then
\$final = StringReplace(\$final, \$constant,\$formula)
EndIf
Next
GuiCtrlSetData(\$effectiveInput, \$final)
EndFunc```

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

×

• Wiki

• Back

• Git

## Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.