Post: [Beginners Guide/Noob] QBasic - The Most Simple Programming Language!
03-03-2011, 01:24 AM #1
(adsbygoogle = window.adsbygoogle || []).push({});
You must login or register to view this content.


Taking computer science within my High School and learning the basics of various programming languages, I have decided to post a user friendly QBasic Guide.

What exactly is QBasic?
Originally posted by another user
QBasic is an IDE and interpreter for a variant of the BASIC programming language which is based on QuickBASIC. Code entered into the IDE is compiled to an intermediate form, and this intermediate form is immediately interpreted on demand within the IDE.[1] It can run under nearly all versions of DOS and Windows, or through DOSBox/DOSEMU, on Linux and FreeBSD.[2] For its time, QBasic provided a state-of-the-art IDE, including a debugger with features such as on-the-fly expression evaluation and code modification.


Now, let's get started, shall we? These next few pages will guide you through the basics in order to support you on your QBasic journey! The Next section will consist of Qbasic download, along with other important information.

[multipage=Getting QBasic]

To program within Qbasic, you obviously will need QBasic itself. You can feel free to download it here where I have uploaded it: You must login or register to view this content.

Once you have downloaded the program, simply extract it to somewhere convenient and open. Please note that this does not require installation as it is DOS Based!

[multipage=Using PRINT Statement]

You must login or register to view this content.

You must login or register to view this content.


Starting off in QBasic, the first thing you should always type as your first line is as followed:
    CLS


CLS clears the screen every time you execute your code, therefore making things much more understandable/comprehensive.

Next, we will start with the basic PRINT statement.

    PRINT "Hello World"


You must login or register to view this content.

You must login or register to view this content.


Typing PRINT followed by "text here" will print the text within the desired quotes, as shown above with Hello World.

Hit:
    F5


Hitting F5 will execute the code which you have inputted into QBasic.

Pressing any key or combining:
    Ctrl + C

will return you back to your programming if and when you wish to exit.

Typing ; behind " " will ensure it all text will stay on the same line:

    PRINT "Hello World!"; "Noticed I Used ; to connect the two lines?";


This concludes the PRINT Statement!


[multipage=Numeric/String Variables]

Thought the PRINT statement was rather easy? Wanting something a bit more challenging? It is time for variables.

Numeric Variable

In order to create a numeric variable, it is a simple as thinking of what to call it!

You must login or register to view this content.

For this example, let's call our numeric variable Number
    cls
number = 5
PRINT "The variable which I have created has the value of"; number


Explaining this, we are assigning 'number' the value of 5. On our next executed line, we are printing a line just as we did in the previous PRINT statement tutorial. At the end of the statement, we wish to state the value of number, therefore we type

    number

Inputting this will take its value and output the end result of the numeric number 5.

You must login or register to view this content.


Strings

We are going to move onto string variables, these, like their counterparts are also rather simple. Strings can be used for numerous things within QBasic.

You must login or register to view this content.


To create a string variable, again we need to think of a reasonable name. For this example, I am going to be using my forums name as the string.

    firstname$ = "Teh"
lastname$ = "Ownage"


This is basically just like numeric variables, but adding a few things into it. EVERY STRING MUST END WITH A $
    $


along with = something surrounded by " "

     = "something"


Anything which is inputted within the quotes will be declared in the String.

With this being said, we will create the program which PRINTS our Strings.

    CLS
PRINT "Hello NextGenUpdate! My Name Is"; firstname$ " " lastname$


Using the PRINT statement, we see "Hello NextGenUpdate, My Name Is" being printed. Not in quotes, we program in our strings which we first created.

    firstname$ " " lastname$


The reasoning for using the " " is to space out the two strings which we declared. Winky Winky

You must login or register to view this content.

This Concludes The Variables Section!


[multipage=INPUT statement]

Now we move onto something a little more interesting. INPUT statement allows us to request information from those using the application. The information they input we save as either a string or numeric value Cool Man (aka Tustin).

You must login or register to view this content.


We are going to start out with CLS as usual. We will start with the following code:

    INPUT "What is your name"; name$


Examining this, the input statement specifies that information will need to be typed in by a user.
    INPUT


    "What is your name";


"What is your name" is just a spin off the the Print Statement. This particular line of code will just be displayed as text in order to instruct the user what to do.

The last part of the code is the most critical and crucial to understand.

    name$


This line of code, which is a STRING variable will be saved according to what the user types in when running the program. If they type in BOB then name$ will equal BOB. The most important part to decide what exactly you want out of the input statement. Do you want them to type in a number? Then you would have

    INPUT "What is your favorite number"; number


rather than

    INPUT "What is your name"; name$


This all going back to the difference between string and numeric variables!

Finally, we will make use of the INPUT statement and variable, by printing what was typed in!

    PRINT "Your name is"; name$


We are using the simple name$ which we created during the INPUT statement, and its value is coming from what the user typed in!

All in all, the end result being this:

You must login or register to view this content.


This concludes the INPUT statements


[multipage=IF statements]

Taking this all in, we have one more rather important thing to learn.

IF statements allow us to make decisions based on what the outcome of certain things will be.

You must login or register to view this content.


Using the prior knowledge of INPUT statements, we will ask the user to type in their favorite website!

    INPUT "What is your favorite website out there"; bestwebsite$


Nothing new here as we are asking the user for a piece of information and saving it as a STRING.

Now is when the IF statement comes into play!

    IF bestwebsite$ = "NextGenUpdate" then 


This is not really that difficult to understand, simply.. if the bestwebsite$ string which the user typed in = "NextGenUpdate" THEN we will do something!

This only applies if the user typed in NextGenUpdate under the input field.

Next, we need to do something if in fact "NextGenUpdate" was inputted.

    PRINT "You are right! It is!"; 


We can simply print that you are right! After all nextgenupdate is the best site around!.

Finishing off everything we must implement a END IF
    END IF


and end of the code, stating that our decision making is over with.

In review:

    INPUT "What is your favorite website out there";bestwebsite$
IF bestwebsite$ = "NextGenUpdate" then
PRINT "You are right! It is!";
END IF


You must login or register to view this content.

This concludes the IF Statements


[multipage=Implementing Colors]

Want to spice up your program in QBasic? Add some color!

You must login or register to view this content.


Adding COLOR [number] will make the text and output of your application the specified color.

    COLOR 4


For example would out the color of red. Whereas typing

    COLOR 5


would output the color of purple.

In summary:

    CLS
COLOR 4
PRINT "Hello NextGenUpdate!";
COLOR 7


    CLS
is clearing the screen.

    COLOR 4
is making the below PRINT statement red.

    COLOR 7
is changing the text color back to white after "Hello NextGenUpdate" is printed in red.

You must login or register to view this content.


[multipage=Practise/Review]

For convenience, I have directed you to our notes and practice programs from school which we have been given. Here you can brush up on your skills and review anything which you may have questions regarding.

PRINT Practice:
You must login or register to view this content.

INPUT Practice:
You must login or register to view this content.

IF Statement Practice:
You must login or register to view this content.

[multipage=Credits/Additional]

This tutorial and guide was written solely by myself, this including all content and screenshots. I wanted to give those a basic underline of all what QBasic has to offer and how easy it can be! I will constantly be updating this thread with more tutorials such as LOOP, and other numerous utilities. I hope everyone enjoyed this thread and if any questions arise, I will gladly answer.

Any errors / mistakes (this includes spelling too) please report to me!

You must login or register to view this content.
Last edited by @KLukas94 ; 03-03-2011 at 01:27 AM.

The following 4 users say thank you to @KLukas94 for this useful post:

KLukas, oToxicity, Ritztro, tylerallmighty
03-03-2011, 01:43 AM #2
Ritztro
I am a Game Developer
Originally posted by Teh
You must login or register to view this content.


Taking computer science within my High School and learning the basics of various programming languages, I have decided to post a user friendly QBasic Guide.

What exactly is QBasic?


Now, let's get started, shall we? These next few pages will guide you through the basics in order to support you on your QBasic journey! The Next section will consist of Qbasic download, along with other important information.

[multipage=Getting QBasic]

To program within Qbasic, you obviously will need QBasic itself. You can feel free to download it here where I have uploaded it: You must login or register to view this content.

Once you have downloaded the program, simply extract it to somewhere convenient and open. Please note that this does not require installation as it is DOS Based!

[multipage=Using PRINT Statement]

You must login or register to view this content.

You must login or register to view this content.


Starting off in QBasic, the first thing you should always type as your first line is as followed:
    CLS


CLS clears the screen every time you execute your code, therefore making things much more understandable/comprehensive.

Next, we will start with the basic PRINT statement.

    PRINT "Hello World"


You must login or register to view this content.

You must login or register to view this content.


Typing PRINT followed by "text here" will print the text within the desired quotes, as shown above with Hello World.

Hit:
    F5


Hitting F5 will execute the code which you have inputted into QBasic.

Pressing any key or combining:
    Ctrl + C

will return you back to your programming if and when you wish to exit.

Typing ; behind " " will ensure it all text will stay on the same line:

    PRINT "Hello World!"; "Noticed I Used ; to connect the two lines?";


This concludes the PRINT Statement!


[multipage=Numeric/String Variables]

Thought the PRINT statement was rather easy? Wanting something a bit more challenging? It is time for variables.

Numeric Variable

In order to create a numeric variable, it is a simple as thinking of what to call it!

You must login or register to view this content.

For this example, let's call our numeric variable Number
    cls
number = 5
PRINT "The variable which I have created has the value of"; number


Explaining this, we are assigning 'number' the value of 5. On our next executed line, we are printing a line just as we did in the previous PRINT statement tutorial. At the end of the statement, we wish to state the value of number, therefore we type

    number

Inputting this will take its value and output the end result of the numeric number 5.

You must login or register to view this content.


Strings

We are going to move onto string variables, these, like their counterparts are also rather simple. Strings can be used for numerous things within QBasic.

You must login or register to view this content.


To create a string variable, again we need to think of a reasonable name. For this example, I am going to be using my forums name as the string.

    firstname$ = "Teh"
lastname$ = "Ownage"


This is basically just like numeric variables, but adding a few things into it. EVERY STRING MUST END WITH A $
    $


along with = something surrounded by " "

     = "something"


Anything which is inputted within the quotes will be declared in the String.

With this being said, we will create the program which PRINTS our Strings.

    CLS
PRINT "Hello NextGenUpdate! My Name Is"; firstname$ " " lastname$


Using the PRINT statement, we see "Hello NextGenUpdate, My Name Is" being printed. Not in quotes, we program in our strings which we first created.

    firstname$ " " lastname$


The reasoning for using the " " is to space out the two strings which we declared. Winky Winky

You must login or register to view this content.

This Concludes The Variables Section!


[multipage=INPUT statement]

Now we move onto something a little more interesting. INPUT statement allows us to request information from those using the application. The information they input we save as either a string or numeric value Cool Man (aka Tustin).

You must login or register to view this content.


We are going to start out with CLS as usual. We will start with the following code:

    INPUT "What is your name"; name$


Examining this, the input statement specifies that information will need to be typed in by a user.
    INPUT


    "What is your name";


"What is your name" is just a spin off the the Print Statement. This particular line of code will just be displayed as text in order to instruct the user what to do.

The last part of the code is the most critical and crucial to understand.

    name$


This line of code, which is a STRING variable will be saved according to what the user types in when running the program. If they type in BOB then name$ will equal BOB. The most important part to decide what exactly you want out of the input statement. Do you want them to type in a number? Then you would have

    INPUT "What is your favorite number"; number


rather than

    INPUT "What is your name"; name$


This all going back to the difference between string and numeric variables!

Finally, we will make use of the INPUT statement and variable, by printing what was typed in!

    PRINT "Your name is"; name$


We are using the simple name$ which we created during the INPUT statement, and its value is coming from what the user typed in!

All in all, the end result being this:

You must login or register to view this content.


This concludes the INPUT statements


[multipage=IF statements]

Taking this all in, we have one more rather important thing to learn.

IF statements allow us to make decisions based on what the outcome of certain things will be.

You must login or register to view this content.


Using the prior knowledge of INPUT statements, we will ask the user to type in their favorite website!

    INPUT "What is your favorite website out there"; bestwebsite$


Nothing new here as we are asking the user for a piece of information and saving it as a STRING.

Now is when the IF statement comes into play!

    IF bestwebsite$ = "NextGenUpdate" then 


This is not really that difficult to understand, simply.. if the bestwebsite$ string which the user typed in = "NextGenUpdate" THEN we will do something!

This only applies if the user typed in NextGenUpdate under the input field.

Next, we need to do something if in fact "NextGenUpdate" was inputted.

    PRINT "You are right! It is!"; 


We can simply print that you are right! After all nextgenupdate is the best site around!.

Finishing off everything we must implement a END IF
    END IF


and end of the code, stating that our decision making is over with.

In review:

    INPUT "What is your favorite website out there";bestwebsite$
IF bestwebsite$ = "NextGenUpdate" then
PRINT "You are right! It is!";
END IF


You must login or register to view this content.

This concludes the IF Statements


[multipage=Implementing Colors]

Want to spice up your program in QBasic? Add some color!

You must login or register to view this content.


Adding COLOR [number] will make the text and output of your application the specified color.

    COLOR 4


For example would out the color of red. Whereas typing

    COLOR 5


would output the color of purple.

In summary:

    CLS
COLOR 4
PRINT "Hello NextGenUpdate!";
COLOR 7


    CLS
is clearing the screen.

    COLOR 4
is making the below PRINT statement red.

    COLOR 7
is changing the text color back to white after "Hello NextGenUpdate" is printed in red.

You must login or register to view this content.


[multipage=Practise/Review]

For convenience, I have directed you to our notes and practice programs from school which we have been given. Here you can brush up on your skills and review anything which you may have questions regarding.

PRINT Practice:
You must login or register to view this content.

INPUT Practice:
You must login or register to view this content.

IF Statement Practice:
You must login or register to view this content.

[multipage=Credits/Additional]

This tutorial and guide was written solely by myself, this including all content and screenshots. I wanted to give those a basic underline of all what QBasic has to offer and how easy it can be! I will constantly be updating this thread with more tutorials such as LOOP, and other numerous utilities. I hope everyone enjoyed this thread and if any questions arise, I will gladly answer.

Any errors / mistakes (this includes spelling too) please report to me!

You must login or register to view this content.


QBasic? Come one dude! C++ all the way!
03-03-2011, 01:45 AM #3
Originally posted by Dutch View Post
QBasic? Come one dude! C++ all the way!


Obviously Winky Winky , only know VERY minor basics of it. Thought I would post this guide for the people who want to learn a extremely easy programming language. You have to start somewhere I suppose.
03-03-2011, 02:25 AM #4
tylerallmighty
Human After All
Nice TuT man. Smile I'll have to take a go at it later when I'm on my laptop.

The following user thanked tylerallmighty for this useful post:

@KLukas94
03-03-2011, 03:27 AM #5
Originally posted by bananaman
Nice TuT man. Smile I'll have to take a go at it later when I'm on my laptop.


Thanks man, took some time to write but I hope everyone enjoys it.I can always help if there's any troubles.

The following 2 users say thank you to @KLukas94 for this useful post:

KLukas, tylerallmighty
03-03-2011, 05:02 AM #6
Ritztro
I am a Game Developer
Originally posted by Teh
Obviously Winky Winky , only know VERY minor basics of it. Thought I would post this guide for the people who want to learn a extremely easy programming language. You have to start somewhere I suppose.


Ya, I just started on c++. Very well written tut though (even though I am not going to use it). Rep+

The following user thanked Ritztro for this useful post:

@KLukas94
03-03-2011, 06:10 AM #7
schnzrs
Do a barrel roll!
Hmmm, kind of cool how the language handles batch commands.

Nice tutorial, btw!
03-03-2011, 01:40 PM #8
tylerallmighty
Human After All
FFFFUUUUUUUUUUUUUUUUU!!!!!!!!!!!!!!:FU: It wont run on Windows 7. :mad:
03-03-2011, 08:33 PM #9
Originally posted by bananaman
FFFFUUUUUUUUUUUUUUUUU!!!!!!!!!!!!!!:FU: It wont run on Windows 7. :mad:


Have you tried running compatibility mode? If you have, I will try uploading another version of qbasic. Also, your computer may not happen to be 64bit, is it?
03-03-2011, 08:38 PM #10
kiwimoosical
Bounty hunter
Visual Logic is actually the easiest. Flow chart programming lolz.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo