Hallo liebe Community,
ich hoffe ihr könnt mir helfen.
Ich möchte ein kleines Programm zur Selbstkontrolle in den Grundrechenarten schreiben.
Wenn ich allerdings einer der Methoden Addieren() , Subtrahieren() [Z. 198 ; 200 ; etc] etc. erneut aufrufen will erhalte ich folgenden Fehler:
C:\Program Files (x86)\AutoIt3\Include\EditConstants.au3 (13) : ==> Can not redeclare a constant.:
Was muss ich tun und was mache ich falsch?
Spoiler anzeigen
; Mathe-Video Übungsprogramm
#include <Misc.au3>
$dll = DllOpen("user32.dll")
Global $Msg = 0
Global $Mathe_Addieren = 0
Global $Mathe_Dividieren = 0
Global $Mathe_Multiplizieren = 0
Global $Mathe_Subtrahieren = 0
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=D:\Daten\Desktop\AutoIt\Laptop\Project Mathe-Video\Forms\Start.kxf
$Form1 = GUICreate("Start", 280, 181, 199, 124)
$Label1 = GUICtrlCreateLabel("Kann ich das?", 40, 32, 183, 37)
GUICtrlSetFont(-1, 22, 800, 4, "Myriad Web Pro")
GUICtrlSetColor(-1, 0xFF0000)
$Dividieren = GUICtrlCreateButton("Dividieren", 144, 120, 105, 25)
$Subtrahieren = GUICtrlCreateButton("Subtrahieren", 144, 88, 105, 25)
$Multiplizieren = GUICtrlCreateButton("Multiplizieren", 8, 120, 105, 25)
$Addieren = GUICtrlCreateButton("Addieren", 8, 88, 105, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Addieren
Global $Mathe_Addieren = 1
Addieren()
Case $Multiplizieren
Global $Mathe_Multiplizieren = 1
Multiplizieren()
Case $Subtrahieren
Global $Mathe_Subtrahieren = 1
Subtrahieren()
Case $Dividieren
Global $Mathe_Dividieren = 1
Dividieren()
EndSwitch
WEnd
Func Addieren() ; Übungen zu Addieren
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=d:\daten\desktop\autoit\laptop\project mathe-video\forms\addieren.kxf
$Addieren = GUICreate("Mathe - Addieren", 641, 86, 192, 124)
Global $Loesung = GUICtrlCreateInput("Loesung", 352, 24, 185, 45)
$x = Random(0, 500, 1)
$y = Random(0, 500, 1)
Global $ergebnis = $x + $y
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Aufgabe: " & $x & " + " & $y & " =", 16, 24, 319, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Check = GUICtrlCreateButton("Überprüfen", 552, 16, 73, 57)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
If _IsPressed("0D", $dll) And $Msg = 0 And WinActive("Mathe -") Then
Check()
EndIf
Sleep(2)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Check
Check()
EndSwitch
WEnd
EndFunc ;==>Addieren
Func Subtrahieren() ; Übungen zu Subtrahieren
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=d:\daten\desktop\autoit\laptop\project mathe-video\forms\addieren.kxf
$Subtrahieren = GUICreate("Mathe - Subtrahieren", 641, 86, 192, 124)
Global $Loesung = GUICtrlCreateInput("Loesung", 352, 24, 185, 45)
$x = Random(0, 500, 1)
$y = Random(0, 500, 1)
While $x < $y
$x = Random(0, 500, 1)
$y = Random(0, 500, 1)
WEnd
Global $ergebnis = $x - $y
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Aufgabe: " & $x & " - " & $y & " =", 16, 24, 319, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Check = GUICtrlCreateButton("Überprüfen", 552, 16, 73, 57)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
If _IsPressed("0D", $dll) And $Msg = 0 And WinActive("Mathe -") Then
Check()
EndIf
Sleep(2)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Check
Check()
EndSwitch
WEnd
EndFunc ;==>Subtrahieren
Func Dividieren() ; Übungen zu Dividieren
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=d:\daten\desktop\autoit\laptop\project mathe-video\forms\addieren.kxf
$Dividieren = GUICreate("Mathe - Dividieren", 641, 86, 192, 124)
Global $Loesung = GUICtrlCreateInput("Loesung", 352, 24, 185, 45)
$x = Random(0, 200, 1)
$y = Random(0, 150, 1)
While IsFloat($x / $y)
$x = Random(0, 200, 1)
$y = Random(0, 150, 1)
WEnd
Global $ergebnis = $x / $y
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Aufgabe: " & $x & " : " & $y & " =", 16, 24, 319, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Check = GUICtrlCreateButton("Überprüfen", 552, 16, 73, 57)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
If _IsPressed("0D", $dll) And $Msg = 0 And WinActive("Mathe -") Then
Check()
EndIf
Sleep(2)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Check
Check()
EndSwitch
WEnd
EndFunc ;==>Dividieren
Func Multiplizieren() ; Übungen zu Multiplizieren
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=d:\daten\desktop\autoit\laptop\project mathe-video\forms\addieren.kxf
$Multiplizieren = GUICreate("Mathe - Multiplizieren", 641, 86, 192, 124)
Global $Loesung = GUICtrlCreateInput("Loesung", 352, 24, 185, 45)
$x = Random(0, 50, 1)
$y = Random(0, 50, 1)
Global $ergebnis = $x * $y
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Aufgabe: " & $x & " * " & $y & " =", 16, 24, 319, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Check = GUICtrlCreateButton("Überprüfen", 552, 16, 73, 57)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
If _IsPressed("0D", $dll) And $Msg = 0 And WinActive("Mathe -") Then
Check()
EndIf
Sleep(2)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Check
Check()
EndSwitch
WEnd
EndFunc ;==>Multiplizieren
Func Check()
$ergebnis2 = GUICtrlRead($Loesung)
If $ergebnis2 = $ergebnis Then
Global $Msg = 1
If MsgBox(1, "Toll", "Richtig. Noch eine Aufgabe?") = 1 Then
If $Mathe_Addieren = 1 Then
Addieren()
ElseIf $Mathe_Dividieren = 1 Then
Dividieren()
ElseIf $Mathe_Multiplizieren = 1 Then
Multiplizieren()
ElseIf $Mathe_Subtrahieren = 1 Then
Subtrahieren()
EndIf
Else
Exit
EndIf
Sleep(200)
Global $Msg = 0
Else
Global $Msg = 1
MsgBox(0, "Leider nicht...", "Bitte versuche es noch einmal")
Sleep(200)
Global $Msg = 0
EndIf
EndFunc ;==>Check
Lg