Sign in to follow this  
Followers 0
maxthailand

I understand the code calculator

3 posts in this topic

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  
Followers 0