QBasic Programming Tutorial 1

Tutorial #1


The first thing we must do, and the most important thing is boot up QBasic..once done we can start! Now, the very first program that we are going to write is very primitive, and it's useless, but it is critical that we go threw all these steps..Type the following:

PRINT "Hello, this is my first program!"

Once done you are ready to execute the program, the easiest way of doing this, you don't have to do it this way, but it is easiest, and fastest is by pushing the F5 key, now. After that has been accomplished, QBasic takes you back to DOS and you see your program in the upper right corner "Hello, this is my very first program!"

Now, a common problem, is that when you execute your program..you still see the text from DOS..like
C:/QBasic
if that happens, don't freak out. The way you handle that problem is by typing in the
CLS
command.Type the following:

CLS


PRINT "Hello, this is my second program!"

All this did was get rid of all the superflous commands in the background. Okay...so far you should not have had any errors, or mistakes..but if you did, try to figure it out, it is all on this tutorial. But if you are really stuck then take your mouse and highlight a command, and press F1, it should give you some help on that particular command.

As of right now, we have learned 2 whole commands!! WHOA!!! But now, now we are going to learn 2 more commands, these commands are confusing, so concentrate! Type the following:

CLS


FOR i=1 TO 10


PRINT "Hello, this is my third program!!"


NEXT i

Run the program, and see what happens...you will see that the phrase "Hello, this is my third program!!" is printed down the screen 10 times. I'll explain.

 

CLS

We know what this does, CLearS the screen

FOR i=1 TO 10

This is what does all the work. "i" is a variable, and "i" stores the value of 1. But everytime the
NEXT
statement comes up, the program will check to see if "i" has reached 10. If it has not, then the program will jump back to the
FOR
command is. You can think of this as a loop...everytime "i" has not reached 10, the program will jump back to
FOR
and increase by 1. You can do this with FOR i = 1 TO 50, you can use any number combination!


I bet there are some questions floatin' threw your head..."What if I want to increase the jump in "i"?" Well, here's how!

CLS


FOR i = 1 TO 10 STEP 2


PRINT "Hello, this is a variation of the previous program!" NEXT i

And what that does is.....press F5.....it counts up to 10 by 2's! You could also have it count by 10's, 100's, any number!!!!

Well, that is it for this tutorial...if the commands that we went through seemed to go by too fast, then read it again, create your own little printing programs!

And ignore the big spaces inbetween the program commands!