Beginners QBasic Tutorial #2
Welcome to the second tutorial! So far you have learned a few commands..CLS..PRINT..FOR..IF..NEXT..STEP..and you learned how to use variables. But now we are going to build upon the variables a little more.
A variable is a little space of memory that you create, and store values that you tell it. You already know how to create and call upon a variable, but, let's do some more advanced variable work!
Now, while creating a program, you are allowed to call a variable what you want, as long as:
- The first character is a letter..
- After the first character you can put whatever you want...
- After the variables name you can put !,#,$,%,&, but you can also leave it blank...
- You cannot name a variable after a comand in QBasic...like:"NEXT"...
Here is a little program going a little further into variables, notice what the name of the variable is, it is named something that might remind you of what it is going to do.
Just to let you know, whenever I stop typing in that typewriter text, that means 2 things...one...the program is over, and two....run the program, so don't wait for me to say "run the program", okay?
Now, what you have seen just now on your computer, is pretty neat. First the program printed out the first value of money, then it printed out the combined value of the old money, and the new value, at least I think it was supposed? If it didn't, then it printed out the new first value of money, then the second!
Now let's talk about a different variation of a variable..a string.
This is just a brief description of strings, mind you!
A string is a way to store info in a variable...here's a little program to type in:
What do you see up there that you haven't used before...? That's right! The money sign! What that does, is indicates a string...get it? $tring!! You must have a $ at the end of a string, if you don't, then the computer will think you have a variable, or it will create an error!
That's it for this tutorial! Go on to some more and see what we talk about next!!!
And again...don't mind the huge spaces inbetween the program command lines! Thanks!!