Page 1 of 1

Help with program

Posted: Tue Jan 10, 2006 12:28 am
by Midnightw
I am trying to create a program that based on your score will give you a certain message. I did it a couple of years back but I dont remember how its bone in basic

example
less than or equal to 500 1 message

greater then 500 but not more than 1000 a different message

greater then 1000 another entierly different message

what do I do?

Posted: Tue Jan 10, 2006 2:26 am
by RayBritton
this might help:

Code: Select all

if score =<500 then 
     print "Message 1"
elseif score =<1000 then 
     print "Message 2"
elseif score > 1000 then 
     print "Message 3"
end if
you probably will want something more complex than just print "Message 1"

=< means equal to and/or lower
=> means equal to and/or higher
> means higher only
< means lower only

Less than or equal to

Posted: Tue Jan 10, 2006 4:50 pm
by Zim
I always write "less than or equal to" this way:

Code: Select all

 if count <= 500 then do stuff
Either way works. I just think it looks better than =<.

Case Structure

Posted: Tue Jan 10, 2006 5:01 pm
by Zim
Oh, and... you can also do it with case structure like this:

Code: Select all


select case score
  case is < 500
       ...do low score stuff
  case 500 to 1000 
       ...do medium score stuff
  case is > 1000
       ...do high score stuff
end select

Also, if you use a "case" structure that can possibly have a "no case" case, you need to provide a "case else" like this:

Code: Select all


select case score
   case is < 500
       ...lo score stuff
   case 500 to 1000
       ...do other stuff
   case else
       ...neither of the above was true
end case

I think case structure reads real nice.

Posted: Wed Jan 11, 2006 2:51 am
by RayBritton
i was going to have a else statement but that would be impossible as every number is covered