James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Im trying to make an If statement where the user enters a number and if it matches a certain number (8 in this example) then a text box produces the word correct, and if it doesnt, the text box produces the word wrong. This is the code i have:
on(press){
if (Answer8.text = "8") {
Result8.text = "Correct"
} else {
Result8.text = "Wrong"
}}
It works if you type in 8, but if you type in anything else, it changes what you typed to 8 and then says correct Any ideas?
Thanks in advance
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
Answer8.text = "8" is assignment not comparison, and is always true, ie. the assignment always succeeds.
You might want Answer8.text == "8") ?
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Mazin it worked, Cheers Ian ur a lifesaver
|