This is an old tutorial I wrote years ago. I hope it comes in handy now for someone.
I will just assume you have already attained a copy of QBasic, and you know how to run it.
We will start out with the most basic command, PRINT. When you write this in QBasic it tells the program to print something. Make sure PRINT is capitalized. You have to specify it to print something like the following:
PRINT "Hello everybody!"
Type that in and go to Start and push RUN, it will print "Hello everybody" at the top of the screen. Notice that what you wanted it to print you surrounded in quotation marks. When you run it, it does not print the quotation marks just everything inside of them. Anything you put in those quotation marks it will print. Try printing a sentence or two.
Note: When QBasic comes to the end of a program it will automatically end it and print "press a key......." at the bottom of the screen. Just follow those directions to get back to QBasic.
When you put CLS anywhere it commands QBasic to clear the screen when you run the program. If you ran the PRINT program more than once you would have noticed that it still had the last printed statement on the RUN screen. If you put CLS at the beginning of a program it clears the RUN screen before it runs the program. Pretty nifty, huh! Try writing the following program:
CLS
PRINT "Hello, everybody!"
Notice that if you run the program more than once it clears the RUN screen.
The INPUT statement is used in most programs when you have to enter something. INPUT tells the computer that you want the person running the program to enter something. Try typing this in.
CLS
INPUT "What is your name?", input$
PRINT input$
We used CLS, INPUT, and PRINT. CLS cleared the screen. INPUT asked you your name and then printed it on the screen. If you look at the end of the INPUT line there is a input$. This is a string (that's what $ means.) It saves whatever you type into the INPUT line as input$. PRINT prints input$ just like it is supposed to. DO NOT SURROUND input$ in quotation marks or it will actually print input$ on the screen. We want it to print what input$ contains. That is why it does not need quotation marks.
Note: If you put a semicolon in place of the comma on the INPUT line, it will make a question mark automatically. The comma does not automatically print a question mark.
Copyright ©2000 by Kyle Baker. Please read our disclaimer.