Firstly an Input Box with a value 0 doesn't look nice. Secondly one could think of exercises where 0 is the solution. In any case an empty Input Box is a better choice. [br]To achieve this you can use use a trick: define [b][i]ans=undefined[/i][/b]. The result is that the inputbox for ans will be empty. But if you fill in a number, this number will show and applied to ans without any problem. In the button [i]new exercise[/i] you can empty the inputbox again with the command [b][i]SetValue(ans, undefined)[/i][/b].[br]See how this works in next applet and try it yourself following the Construction Steps.
[table][tr][td]1[/td][td][/td][td]Type the command [b]a = RandomBetween(1, 10)[/b] to create the integer a.[/td][/tr][tr][td]2[/td][td][/td][td]Type the command [b]b = RandomBetween(1, 10)[/b] to create the integer b.[/td][/tr][tr][td]3[/td][td][/td][td]Type the command [b]sol = a + b[/b] to create the integer sol.[/td][/tr][tr][td]4[/td][td][/td][td]Type the command [b]ans = undefined[/b] to create the integer ans.[br][/td][/tr][tr][td]5[/td][td][icon]/images/ggb/toolbar/mode_text.png[/icon][/td][td]Type the dynamic text [b]a + b[/b] and select a and b in the list of available objects.[/td][/tr][tr][td]6[/td][td][icon]/images/ggb/toolbar/mode_textfieldaction.png[/icon][/td][td]Select the Input Box Tool and create an Input Box with label [b]=[/b] linked to the object [b]ans[/b].[br][/td][/tr][tr][td]7[/td][td][icon]/images/ggb/toolbar/mode_buttonaction.png[/icon][/td][td]Select the Button Tool and create a button with label [b]next exercise[/b] and type as script the commands [b]UpdateConstruction()[/b] and [b]SetValue(ans, undefined)[/b] to empty the Input Box again.[br][/td][/tr][tr][td][/td][td][/td][td][/td][/tr][/table]
To give feedback on the answer you can show texts as [i]CORRECT [/i]or [i]FALSE[/i]. But you might as well use dynamic colors to color the inputbox red if the given answer is false, green if the answer is correct and black if no answer is given yet.[br]We only want the inputbox to color red if only an answer is already been given, in other words if ans is no longer undefined. This we can check with the condition [b]ans == ans[/b], since number is equal to itself unless it's undefined. [br]Note that the double == signs will turn into the logic equal with question mark above it after tapping the Enter-tab.[br]