Hey Community,
hab da mal einen kleinen Taschenrechner programmiert.
Klappt alles wunderbar ausser das ich nicht wirklich weiß wie ich nach jeder Subtraktion/Addition/Multiplikation/Division das Inputfeld wieder "leeren" kann so das man direkt die nächste Aufgabe eintippen kann.
Hat jemand von euch eine Idee?
Hier das Script
Spoiler anzeigen
#include <GUIConstants.au3>
$Form1 = GUICreate("Rechner", 151, 102, 193, 125)
$Button1 = GUICtrlCreateButton("1", 0, 78, 25, 25, 0)
$Button2 = GUICtrlCreateButton("2", 26, 78, 25, 25, 0)
$Button3 = GUICtrlCreateButton("3", 52, 78, 25, 25, 0)
$Button4 = GUICtrlCreateButton("4", 0, 52, 25, 25, 0)
$Button5 = GUICtrlCreateButton("5", 26, 52, 25, 25, 0)
$Button6 = GUICtrlCreateButton("6", 52, 52, 25, 25, 0)
$Button7 = GUICtrlCreateButton("7", 0, 26, 25, 25, 0)
$Button8 = GUICtrlCreateButton("8", 26, 26, 25, 25, 0)
$Button9 = GUICtrlCreateButton("9", 52, 26, 25, 25, 0)
$input = GUICtrlCreateInput("", 0, 0, 151, 21,$ES_NUMBER)
$Button10 = GUICtrlCreateButton("=", 98, 26, 53, 25, 0)
$Button11 = GUICtrlCreateButton("+", 98, 78, 25, 25, 0)
$Button12 = GUICtrlCreateButton("-", 126, 78, 25, 25, 0)
$Button13 = GUICtrlCreateButton("*", 98, 52, 25, 25, 0)
$Button14 = GUICtrlCreateButton("/", 126, 52, 25, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($input, GUICtrlRead($input) & 1)
Case $Button2
GUICtrlSetData($input, GUICtrlRead($input) & 2)
Case $Button3
GUICtrlSetData($input, GUICtrlRead($input) & 3)
Case $Button4
GUICtrlSetData($input, GUICtrlRead($input) & 4)
Case $Button5
GUICtrlSetData($input, GUICtrlRead($input) & 5)
Case $Button6
GUICtrlSetData($input, GUICtrlRead($input) & 6)
Case $Button7
GUICtrlSetData($input, GUICtrlRead($input) & 7)
Case $Button8
GUICtrlSetData($input, GUICtrlRead($input) & ![]()
Case $Button9
GUICtrlSetData($input, GUICtrlRead($input) & 9)
Case $Button10
$ergebniss = StringSplit(GUICtrlRead($input), "+")
If Not @error = 1 Then
GUICtrlSetData($input, $ergebniss[1] + $ergebniss[2])
EndIf
$ergebniss = StringSplit(GUICtrlRead($input), "-")
If Not @error = 1 Then
GUICtrlSetData($input, $ergebniss[1] - $ergebniss[2])
EndIf
$ergebniss = StringSplit(GUICtrlRead($input), "*")
If Not @error = 1 Then
GUICtrlSetData($input, $ergebniss[1] * $ergebniss[2])
EndIf
$ergebniss = StringSplit(GUICtrlRead($input), "/")
If Not @error = 1 Then
GUICtrlSetData($input, $ergebniss[1] / $ergebniss[2])
EndIf
Case $Button11
GUICtrlSetData($input, GUICtrlRead($input) & "+")
Case $Button12
GUICtrlSetData($input, GUICtrlRead($input) & "-")
Case $Button13
GUICtrlSetData($input, GUICtrlRead($input) & "*")
Case $Button14
GUICtrlSetData($input, GUICtrlRead($input) & "/")
EndSwitch
WEnd