Edit box question
Im making a simple math game for children for an assignment. The program generates two numbers and the student has to type in the correct answer. I have an edit box for the answer to be typed in and a mark button beside it.
Is there any way to display an error message if nothing has been entered into the edit box and the mark button clicked?
Thanx for any help,
Is this a Windows assignment? You can determine whether the edit box has text by calling GetWindowText and checking the length of the text with the strlen function. Then, call MessageBox to display a message if no text has been entered.
Yes this is windows, i should have put it in the other forum. Would it be possible for you to write an example with this 'GetWindowText' and checking the length?
In your case, you also need to validate the string and check if it's an integer, using either the strtol function or the atoi function.
To make sure the student only enters numbers, set the ES_NUMBER style to the edit box, as follows:
Thanx 4 all your help m8, it came in handy - have got it all working now.
also add the edit style so the edit will only allow numbers to be typed in (so you don't have to validate the data too much)
either add in the resource editor
on the fly
You can also use EM_MODIFY to find out if the content of
the edit box has been changed.
examine its return value(SendMessage) for true or false.