Jump to content
Sign in to follow this  
anony10

Calculator

Recommended Posts

anony10

Hi.

I did a calculator.

(okay, if u have better dont need to post)

I know bug: u can write letters too, but i dont know how to fix it.So if you know, how to, pls write.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Calculator", 367, 210, 192, 124)
$Input1 = GUICtrlCreateInput("", 32, 51, 121, 21)
$Radio1 = GUICtrlCreateRadio("-", 160, 24, 29, 17)
$Radio2 = GUICtrlCreateRadio("+", 160, 44, 29, 17)
$Radio3 = GUICtrlCreateRadio("*", 160, 63, 30, 17)
$Radio4 = GUICtrlCreateRadio("/", 160, 83, 28, 17)
$Input2 = GUICtrlCreateInput("", 195, 50, 121, 21)
$Button1 = GUICtrlCreateButton("=", 79, 108, 182, 25, 0)
$Input3 = GUICtrlCreateInput("", 110, 148, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   $kivon = BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)
   $osszead = BitAnd(GUICtrlRead($Radio2),$GUI_CHECKED)
   $szoroz = BitAnd(GUICtrlRead($Radio3),$GUI_CHECKED)
   $oszt = BitAnd(GUICtrlRead($Radio4),$GUI_CHECKED)
   If $kivon = 1 Then
    kivonas()
   EndIf
  
   If $osszead = 1 Then
    osszeadas()
   EndIf
   
   If $szoroz = 1 Then
    szorzas()
   EndIf
  
   If $oszt = 1 Then
    osztas()
   EndIf
  
   If $kivon + $osszead + $szoroz + $oszt = 0 Then
    msgbox(0, "Error", "Choose from any radio buttons!")
   EndIf
EndSwitch
WEnd
Func kivonas()
$put1 = GuiCtrlRead ($input1)
$put2 = GuiCtrlRead ($input2)
$kivonasss = $put1 - $put2
GuiCtrlSetData ($Input3, $kivonasss)
EndFunc
Func osszeadas()
$put1 = GuiCtrlRead ($input1)
$put2 = GuiCtrlRead ($input2)
$osszeadasss = $put1 + $put2
GuiCtrlSetData ($Input3, $osszeadasss)
EndFunc
Func szorzas()
$put1 = GuiCtrlRead ($input1)
$put2 = GuiCtrlRead ($input2)
$szorzasss = $put1 * $put2
GuiCtrlSetData ($Input3, $szorzasss)
EndFunc
Func osztas()
$put1 = GuiCtrlRead ($input1)
$put2 = GuiCtrlRead ($input2)
$osztasss = $put1 / $put2
GuiCtrlSetData ($Input3, $osztasss)
EndFunc

Share this post


Link to post
Share on other sites
JohnOne

Hi.

I did a calculator.

(okay, if u have better dont need to post)

I know bug: u can write letters too, but i dont know how to fix it.So if you know, how to, pls write.

$Input3 = GUICtrlCreateInput("", 110, 148, 121, 21,$ES_NUMBER)
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
anony10

Thx! :graduated:

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×