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

Post Reply
User avatar
myuusmeow
Newbie
Posts: 3
Joined: Sun May 14, 2006 7:06 pm

VERY Simple IF Question

Post by myuusmeow » Sun May 14, 2006 7:23 pm

(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.

MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows » Sun May 14, 2006 7:50 pm

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!

MystikShadows

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

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

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

Post by myuusmeow » Sun May 14, 2006 7:58 pm

Hey, thanks for the quick reply! :D It worked great... I think, I can't guess the number to test it :P.

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Sun May 14, 2006 8:45 pm

Out of the past come the thundering hoofs of the great horse Silver --- MysticShadows rides again....

MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows » Sun May 14, 2006 8:48 pm

Wow, I positively love that moneo. Can I use it? hehe...
When God created light, so too was born, the first Shadow!

MystikShadows

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

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

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Mon May 15, 2006 8:12 pm

MystikShadows wrote:Wow, I positively love that moneo. Can I use it? hehe...
Only if you leave me a silver bullet next time you help me out. :wink:

Post Reply