Jump to content

I understand the code calculator


Recommended Posts

I try to program a calculator. But I do not know why my code does not work. I fixed itfor me.

#include <GUIConstants.au3>
#include <EditConstants.au3>
Global  $Noo
$Form1_1 = GUICreate("โปรแกรมคิดเลข", 266, 338, 434, 123)
$Noo = GUICtrlCreateInput("", 16, 24, 233, 21,BitOR($ES_RIGHT,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN))
$CC = GUICtrlCreateButton("C", 208, 120, 41, 33, 0)
$7 = GUICtrlCreateButton("7", 16, 120, 41, 33, 0)
$8 = GUICtrlCreateButton("8", 80, 120, 41, 33, 0)
$9 = GUICtrlCreateButton("9", 144, 120, 41, 33, 0)
$h = GUICtrlCreateButton("/", 208, 176, 41, 33, 0)
$4 = GUICtrlCreateButton("4", 16, 176, 41, 33, 0)
$5 = GUICtrlCreateButton("5", 80, 176, 41, 33, 0)
$6 = GUICtrlCreateButton("6", 144, 176, 41, 33, 0)
$C = GUICtrlCreateButton("*", 208, 232, 41, 33, 0)
$1 = GUICtrlCreateButton("1", 16, 232, 41, 33, 0)
$2 = GUICtrlCreateButton("2", 80, 232, 41, 33, 0)
$3 = GUICtrlCreateButton("3", 144, 232, 41, 33, 0)
$D = GUICtrlCreateButton("-", 208, 288, 41, 33, 0)
$T = GUICtrlCreateButton("=",  16, 64, 233, 33)
$0 = GUICtrlCreateButton("0", 16, 288, 41, 33, 0)
$G = GUICtrlCreateButton(".", 80, 288, 41, 33, 0)
$B = GUICtrlCreateButton("+", 144, 288, 41, 33, 0)
GUISetState(@SW_SHOW)
While 1
$read = GUICtrlRead($Noo)
$No = GUICtrlRead($Noo)
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $1
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&1)
  Case $2
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&2)
  Case $3
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&3)
  Case $4
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&4)
  Case $5
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&5)
  Case $6
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&6)
  Case $7
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&7)
  Case $8
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&8)
  Case $9
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&9)
  Case $0
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&0)
  Case $G
   GUICtrlSetData($Noo, GUICtrlRead($Noo)&".")
  Case $B
    GUICtrlSetData($Noo,GUICtrlRead($Noo)&"+")
  Case $D
    GUICtrlSetData($Noo,GUICtrlRead($Noo)&"-")
  Case $C
    GUICtrlSetData($Noo, GUICtrlRead($Noo)&"*")
  Case $h
    GUICtrlSetData($Noo,GUICtrlRead($Noo)&"/")
       Case $T
            GUICtrlSetData($Noo,GUICtrlRead($Noo))
  Case $CC
   GUICtrlSetData($Noo,"")
EndSwitch
WEnd
Link to comment
Share on other sites

Change your Case$T to:

Case $T
   GUICtrlSetData($Noo, Execute(GUICtrlRead($Noo)))

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...