Hi all,
Can't find a solution to my problem.
- The user get ask a math question and is expected to enter the answer in a textbox, it always numbers
- The user should not need to validate the answer with enter, if the answer expected is a one digit long then, as soon as the user press a digit (or any key) the program should go an compare to see if the user is correct. If two digit is expected then verification is done only when the user press the second digit. The program should be responsive otherwise i.e. if the user want to exit he should still be able to click on file -> exit.
- The user get ask a pre-defined number of questions
- The next question is displayed only if the current question is answered correctly
Here an example with three questions
1) What's 1 + 1. user enters 2, check is performed and program go to next question
2) What's 10 + 10. User enters 2, nothing happen, then user enters 0, check is performed and program go to next question
3) What's 100 + 100. User enters 2, nothing happen, then user enters 0, nothing happen, then user enters 0 again, check is performed and program finish
Look like the KeyPress would be the event I am looking for but don't how I would implement it for my scenario, since it would imply that the KeyPress is inside a for loop (in my example for loop will be from 1 to 3).
In other word I don't know how to create a for loop and get to the next item of that loop only when condition is satisfied inside that loop (user has answered correctly or user exit the program).
Would something like this work?
For loop (i=1 to 3)
wait for KeyPress
when KeyPress, if textbox contain incorrect length wait for KeyPress (go to the previous line)
else verify user answer, if correct i++, if incorrect user answer, clear textbox and go back to "wait for KeyPress"
end loop
Any light will be really appreciated
Fabou