An Adventure in Coding with QB64: A Beginner’s Guide for Young Minds

This entry is part 1 of 2 in the series Coding For Kids

Post Stastics

  • This post has 2010 words.
  • Estimated read time is 9.57 minute(s).

Introduction: Let’s Dive into the World of BASIC

Welcome, young minds, to the exciting journey of coding! Today, we are going to embark on an adventure with QB64, a special tool that will help us bring our ideas to life through programming.

But first, what is programming? Think of it as giving instructions to a computer, telling it what to do. And just like learning a new language, we’ll start with something simple – BASIC.

BASIC stands for Beginners’ All-purpose Symbolic Instruction Code. It’s a friendly language that helps us communicate with computers by providing straightforward commands. Today, we’re going to use QB64, a modern version of BASIC that makes coding even more fun!

{"question":"What does BASIC stand for?","answers":["Beginners All Purpose Flour","Buy Another Strawberry Ice cream","Beginners All purpose Symbolic Instruction Code"],"correctAnswer":2}
{"question":"What is Programming","answers":["Deciding what to watch on television","Giving instructions to a computer","Watching a DVD"],"correctAnswer":1}

Getting Started: Installing QB64

Before we dive into coding, let’s set up our coding playground. We’ll need to install QB64 on our computer. You can think of QB64 as a magic pen that turns our ideas into computer programs.

  1. Visit the QB64 website: Go to to download QB64 for your computer.
  2. Download and Install: Follow the instructions on the website to download and install QB64. If you get stuck, don’t worry – you can always ask for help from a grown-up or your mentor.
  3. Launch QB64: Once installed, open QB64. It might look a bit like magic spells, but don’t worry, we’ll help you understand it step by step!

Now that we have our magic pen ready, let’s create our first enchanting spell – a “Hello, World!” program.

Our First Spell: Hello, World!

In coding, a “Hello, World!” program is like saying “Abracadabra” to test if our magic pen is working. Let’s create one together:

PRINT "Hello, World!"

Let’s break it down:

  • PRINT: This command tells the computer to display something. In this case, it’s our magical greeting.
  • "Hello, World!": This is the message we want to display. You can change this to anything you like!

Now, run your program by pressing F5 on your keyboard. You should see your magical greeting appear on the screen. Congratulations! You’ve just cast your first spell in the world of coding.

{"question":"What does the PRINT command do?","answers":["Turns on the printer","Prints shipping labels","Tells the computer to display something"],"correctAnswer":2}

Adding a Personal Touch: Taking Your Name as Input

Let’s make our program even more magical by taking your name as input and using it in our greeting. Here’s how we can modify our spell:

INPUT "What's your name? "; name$
PRINT "Hello, "; name$; "!"

Now, let’s understand the new parts:

  • INPUT "What's your name? "; name$: This line asks for your name. The name$ part is like a special container that holds whatever you type.
  • PRINT "Hello, "; name$; "!": Here, we use your name to personalize our greeting. The ; is like a magical glue that joins different pieces together.

Run the program again, and this time, it will ask for your name before casting the spell. Exciting, isn’t it?

{"question":"What does the INPUT command do?","answers":["Asks the user for input","Ask another computer for data","Gets the printer's opinion"],"correctAnswer":0}

Understanding the Magic Words: Data Types in QB64

In the magical realm of coding, different types of data exist. Let’s explore a few with some spells:


num1 = 5
num2 = 7
result = num1 + num2
PRINT "The sum is: "; result
  • num1 and num2 are like containers for enchanted numbers.
  • result = num1 + num2: Here, we add the enchanted numbers to get a new enchanted number and store it in a container called result.


text$ = "Magical Text"
PRINT "The spell says: "; text$
  • text$ is a container for magical words.
  • containers for data are called variables.
  • text in programming is called a string.
  • in QB64 all string variables end with a $


TRUE = 1

isMagic = TRUE

IF isMagic THEN
    PRINT "It's a magical day!"
    PRINT "No magic today."
  • We first define TRUE as 1 and FALSE as 0. Then we assign TRUE to isMagic.
  • isMagic is a magical switch that can be either TRUE or FALSE.
  • Boolean variables can only hold one of two values TRUE or FALSE.
  • The IF statement checks the boolean value held in the variable isMagic.
  • If the value in isMagic is TRUE the THEN statement runs all the code between it and the ELSE statement.
  • The ELSE statement runs the code between it and the END statement if the value tested by IF is FALSE.
  • You can omit the ELSE statement when not needed.
  • Boolean variables are often used for making decision in programs.
{"question":"What is a variable?","answers":["Something that always changes","A container for data (information)","A large spot on Saturn"],"correctAnswer":1}
{"question":"Boolean type data can have how many different values?","answers":["2","5","7"],"correctAnswer":0}
{"question":"You must always use an ELSE statement with an IF statement. True or False?","answers":["TURE","FALSE"],"correctAnswer":1}
{"question":"What type of data (text, number, boolean) would a variable named value store?","answers":["Number","Text","Number or Boolean","Boolean","Number or Text"],"correctAnswer":2}

The Art of Magic: Abstraction and Program Design

Now that we’ve learned some spells, let’s talk about the art of magic – abstraction. Abstraction is like having a magic wand that lets us hide complex details and focus on the big picture. Kind of like how up close you can see all the branches and leaves on a tree. But far away, you can only see the shape and colors. You still know its a tree. But the details are hidden from you. Abstraction is hiding the details to concentrate on the bigger picture (the tree instead of the leaves and branches).

Imagine we want to cast a spell to multiply two numbers. Instead of showing every detail, we can create a magic wand (a function) like this:

' Prepare arguments
num1 = 3
num2 = 4

' Call function and display results
PRINT "The product is: "; MultiplyNumbers(num1, num2)

' Define function
FUNCTION MultiplyNumbers(a, b)
    result = a * b
    MultiplyNumbers = result

Here, MultiplyNumbers is our magic wand. We give it two numbers, and it gives us the result. This makes our spells more organized and easier to understand. A FUNCTION abstracts away the details from the rest of the program. Other parts of the program don’t need to know how the two numbers are multiplied together, they just need to know the FUNCTION MultiplyNumbers takes two numbers as arguments, and pass two numbers to MultiplyNumbers when it calls it.

Arguments & Parameters

Imagine you’re throwing a birthday party, and you’ve invited some friends. Now, let’s talk about your party plan.

Parameters are like the details you decide before the party begins. For example, you might decide that your party will have a theme like superheroes, and you’ll have two games: musical chairs and a treasure hunt. These details are your parameters—they’re the plans you set in advance.

Arguments, on the other hand, are the actual friends who come to your party. When your friends arrive, they bring their own unique personalities and characteristics. Some might love playing musical chairs, while others might be really good at solving clues in the treasure hunt. These unique qualities that your friends bring to the party are like the arguments—they’re the specific values that match the parameters you set.

So, in programming, parameters are like the plans you make (the theme, the games), and arguments are the actual values that you use when you run the program (the friends who bring their own qualities to the party).

{"question":"In the MultiplyNumbers(a, b) above, a and b are?","answers":["Parameters","Arguments"],"correctAnswer":0}
{"question":"If I call: MultiplyNumbers(6, 5), the values 6 and 5 are?","answers":["Parameters","Arguments"],"correctAnswer":1}

Crafting a Magical Calculator

Let’s use our new found magic to create a small calculator program. This spell will add or subtract two numbers, depending on your choice:

INPUT "Enter the first number: "; num1
INPUT "Enter the second number: "; num2

INPUT "Choose an operation (1 for addition, 2 for subtraction): "; choice

IF choice = 1 THEN
    result = num1 + num2
    operation$ = "addition"
    result = num1 - num2
    operation$ = "subtraction"

PRINT "The result of the "; operation$; " is: "; result

This spell takes two numbers and asks if you want to add or subtract them. It then performs the chosen operation and reveals the result.

Going Further: Deepen Your Spellcasting Skills

Congratulations on mastering the basics of QB64! Now, let’s delve deeper into the magical world of coding with a few enchanting exercises tailored to your current knowledge.

1. Spellbinding Mad Libs: Enhance Your Text Manipulation Skills

Extend your magical prowess by creating a Mad Libs-style program. Ask the user for various words (nouns, verbs, adjectives) and use them to construct a whimsical and humorous story. This exercise will strengthen your understanding of user input and string manipulation.

INPUT "Give me a noun: "; noun$
INPUT "Choose a verb: "; verb$
INPUT "Pick an adjective: "; adjective$

PRINT "Once upon a time, there was a "; adjective$; " "; noun$; " who loved to "; verb$; ". The end."

Experiment with different story templates and see how creative you can get with your storytelling!

2. Magical Number Guessing: Unleash the Power of Conditional Statements

Craft a mystical number guessing game to challenge your friends or even your mentor. Generate a random number and have the player guess it. Provide hints like “too high” or “too low” until they discover the magical number. This exercise will deepen your understanding of conditional statements and user interaction.

magicNumber = INT(RND * 100) + 1  ' Generate a random number between 1 and 100

    INPUT "Guess the magical number (between 1 and 100): "; userGuess

    IF userGuess = magicNumber THEN
        PRINT "Congratulations! You've found the magical number!"
    ELSEIF userGuess < magicNumber THEN
        PRINT "Too low! Try again."
        PRINT "Too high! Try again."
    END IF
LOOP UNTIL userGuess = magicNumber

Experiment with different ranges for the magical number and make the game more challenging!

3. Interactive Personal Journal: Combine Input and String Manipulation

Create a magical personal journal program where the user can input their thoughts and feelings. Use string manipulation to store and display the entries in a creative format. This exercise will reinforce your skills in handling user input and working with strings.

DIM journalEntries$(5)  ' Create an array to store journal entries

FOR i = 1 TO 5
    INPUT "Write an entry for today: "; journalEntries$(i)

PRINT "Your Magical Journal:"
FOR i = 1 TO 5
    PRINT i; ". "; journalEntries$(i)

Experiment with different ways to display the journal entries and consider adding timestamps for extra magic!

These exercises will deepen your understanding of the magical spells you’ve already learned. As you embark on these adventures, remember that the true magic lies in your creativity and curiosity. Happy coding, young sorcerer!

{"question":"What does pressing F5 do in QB64?","answers":["Launches a missile","Changes the screen color","Runs a program","Stops a running program"],"correctAnswer":2}

Conclusion: Your Journey into the Magical World of Coding

Congratulations, young coder! You’ve taken your first steps into the enchanting world of QB64. We’ve learned the magic words of BASIC, created spells to greet the world, personalized our spells, explored different types of magic (data types), and even crafted a magical calculator.

Remember, coding is like learning to be a wizard. The more spells you learn, the more powerful you become. Don’t be afraid to experiment and create your own magical incantations!

Next time we will cover loops and more!

Resources: Your Magical Library

  1. QB64 Official Website: The home of QB64, your magical coding pen.
  2. QB64 Wiki: A magical book filled with knowledge about QB64.
  3. QB64 Forum: A place to meet other wizards and share your magical discoveries.
  4. QB64 Phoenix: A forum for QB64 enthusiasts.
  5. QB64 Development Team Repository: The official code, YouTube videos, and more.
  6. QB64 Tutorial: A QB64 PE (Phoenix Edition) tutorial and information.

Keep coding and may your spells always run smoothly!

Series NavigationMore BASICs And Personalizing Spells with User Input >>

Leave a Reply

Your email address will not be published. Required fields are marked *