Sign in to follow this  
fuchu

QB scoring problem

Recommended Posts

fuchu    100
Here is my source: ( If any HTML shows, ignore it.) <htmL> <body> <title> QB Help</title> "CLS DIM score$ PRINT" Welcome to TS2Trivia/TS2U Trivia .47!" INPUT " Whate website can you get TheSims2 Enhancer from "; TS2E$ ' Select the variable SELECT CASE TS2$ CASE "sims2programs.com" LOCATE 12, 16 PRINT "SCORE:"; PRINT score$ + "1" END SELECT Then I add another question but when I answer correct it is still 1. Do I need to make an array? What can I do? Please help." </html> </body>

Share this post


Link to post
Share on other sites
Scet    960
Quote:
Original post by fuchu
INPUT " Whate website can you get TheSims2 Enhancer from "; TS2E$
SELECT CASE TS2$


Shouldn't TS2$ be TS2E$?

This is one of the(many) problems with QB. You can just create variables anywhere so typos then go unnoticed.

Share this post


Link to post
Share on other sites
Oberon_Command    6089
You know, you can specify OPTION EXPLICIT in QB so that you have to declare variables before you use them. Here's an example:

'beginning of program
print "this is a variable", x

That is perfectly valid QB(and FB) code, but x will always be 0 unless you initialize it. However, if you want to use OPTION EXPLICIT, you cannot use a variable without declaring it first. So, this:

option explicit
'beginning of program
print "this is a variable", x

would be invalid and you would get an error. You would have to make it this:

option explicit
dim x as integer
x = 0
'beginning of program
print "this is a variable", x

for that to work. So that's one remedy for a QB problem.

Share this post


Link to post
Share on other sites
fuchu    100
I remember the option explicit command from php, which I stilll need to learn better. I hope that helped me. Thanks.

Share this post


Link to post
Share on other sites
mnansgar    421
PRINT "SCORE:"; PRINT score$ + "1"

The above line doesn't actually increment the score$ variable. To actually increment the variable, you should type:

PRINT "SCORE:"
score$ = score$ + 1
PRINT score$

In your code, you only printed score$ + "1" to the screen (you probably meant score$ + 1), but you did not store the result anywhere.

Share this post


Link to post
Share on other sites
Daerax    1207
As pointed out by mnangsar, since score$ is initialized to "" , you were outputting "" + "1" or "1" everytime. Also however, note that in QB having the '$' sign at the end of a variable designates it as a string. So even score$= score$ + 1 would leave you with unwonted results, youd get "111111..." for however many times you concatenate 1 to your string. You need to hold your score with an integer and display that.

CLS
DIM score% 'dim score as integer
PRINT" Welcome to TS2Trivia/TS2U Trivia .47!"
INPUT " Whate website can you get TheSims2 Enhancer from "; TS2E$
' Select the variable
SELECT CASE TS2E$

CASE "sims2programs.com"
score% = score% + 1
LOCATE 12, 16
PRINT "SCORE:"; score%
END SELECT

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this