VERY Simple IF Question

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

myuusmeow
Newbie
Posts: 3
Joined: Sun May 14, 2006 7:06 pm

VERY Simple IF Question

(I just started learning BASIC yesterday, and want to be "ok" with it by June 14, my birthday.)

Code: Select all

``````CLS
PRINT "Guess the Random Number"
PRINT "Hint: It is less than 11"
PRINT "Only 3 chances!"
RANDOMIZE TIMER
number = INT(RND * 10)
INPUT "1st chance?", number1
IF number1 = number THEN PRINT "You won!" ELSE PRINT "Too bad."
INPUT "2nd chance!", number2
IF number2 = number THEN PRINT "You won!" ELSE PRINT "Oh no!"
INPUT "3rd, and last chance!!!", number3
IF number3 = number THEN PRINT "You won!" ELSE PRINT "Too bad, it was "; number; "."
``````
In

Code: Select all

``... = number THEN PRINT "You won"``
, I want to put an END in there, but, I can't.
I've tried

Code: Select all

``... = number THEN PRINT "You won!" END``
and

Code: Select all

``... = number THEN PRINT "You won!" AND END``
.

Otherwise I got it right, and it keeps going.

Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:
Hi there myuusmeow

you were very close

... = number THEN PRINT "You won!" END

should be

... = number THEN PRINT "You won!": END

not the colon before your END statement..that should work for you
When God created light, so too was born, the first Shadow!

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com

myuusmeow
Newbie
Posts: 3
Joined: Sun May 14, 2006 7:06 pm
Hey, thanks for the quick reply! It worked great... I think, I can't guess the number to test it .

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico
Out of the past come the thundering hoofs of the great horse Silver --- MysticShadows rides again....

Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:
Wow, I positively love that moneo. Can I use it? hehe...
When God created light, so too was born, the first Shadow!