Es gäbe auch noch die Möglichkeit, Richtig oder Falsch in die Antworten zu speichern:
Spoiler anzeigen
AutoIt
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Global $aQA[6][5] = [ _
[' Frage1', 'rAntwort1', 'fAntwort2', 'fAntwort3', 'fAntwort4'], _
[' Frage2', 'fAntwort1', 'rAntwort2', 'fAntwort3', 'fAntwort4'], _
[' Frage3', 'fAntwort1', 'fAntwort2', 'rAntwort3', 'fAntwort4'], _
[' Frage4', 'fAntwort1', 'fAntwort2', 'fAntwort3', 'rAntwort4'], _
[' Frage5', 'rAntwort1', 'fAntwort2', 'fAntwort3', 'fAntwort4'], _
[' Frage6', 'fAntwort1', 'rAntwort2', 'fAntwort3', 'fAntwort4']]
Global $hGui = GUICreate('Quiz', 640, 200)
Global $aidQA[5], $iCount = 0, $iIndex
$aidQA[0] = GUICtrlCreateLabel('', 10, 10, 600, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, 'Arial')
For $i = 0 To UBound($aidQA) - 2
$aidQA[$i + 1] = GUICtrlCreateButton('', 20 + Mod($i, 2) * 320, 50 + Int($i / 2) * 50, 280, 30)
GUICtrlSetFont(-1, 14, 400, 0, 'Arial')
Next
_NextQuestion()
GUISetState()
Global $aMsg
While True
$aMsg = GUIGetMsg(1)
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
Exit
Case $aidQA[1] To $aidQA[4]
$iIndex = $aMsg[0] - $aidQA[0]
If StringLeft($aQA[$iCount][$iIndex], 1) = 'r' Then
MsgBox(0, 'Antwort', 'Richtig!')
Else
MsgBox(0, 'Antwort', 'Falsch!')
EndIf
$iCount += 1
If $iCount = UBound($aQA) Then $iCount = 0
_NextQuestion()
EndSwitch
WEnd
Func _NextQuestion()
For $i = 0 To UBound($aidQA) - 1
GUICtrlSetData($aidQA[$i], StringMid($aQA[$iCount][$i], 2))
Next
EndFunc
Alles anzeigen