Welcome to the Online Programming Course organized by Armstrong Computers College | Armstrong IT Training & Software Hub. The first lesson of this course is the Orientation Session. Here, participants will be introduced to:- The structure of the course and what to expect in each module.The languages to be studied (QBasic, C++, Python & JavaScript).The duration, schedule, and cost model of the program.The importance of programming in today’s digital world.How to access support, WhatsApp group discussions, and course materials. This session is meant to help you settle in, understand the roadmap, and get motivated for the learning journey ahead.
In this module, we continue our journey into programming by introducing one of the earliest and most widely used beginner-friendly programming languages: QBasic. This curriculum is designed to help participants understand the fundamental principles of programming using QBasic as a foundation. By the end of this module, you will be able to write, run, and debug simple programs while also learning the logical thinking skills necessary to advance into modern programming languages.
Welcome to today’s lesson, The Other Way to Declare a Variable in QBasic.
In our previous class, we learned the first way to declare a variable using type declaration characters such as $, %, &, !, and #.
In this lesson, we are taking a deeper look at another method of declaring variables, using the DIM statement with AS to define variable types more clearly and professionally in QBasic.
The second method is more descriptive and is commonly used in professional coding. It makes your program easier to read and understand.
DIM [VariableName] AS [DataType]
DIM name AS STRING
DIM age AS INTEGER
DIM amount AS SINGLE
DIM salary AS DOUBLE
DIM studentID AS LONG
This tells QBasic the type of data each variable will hold.
DIM Numn1 AS INTEGER
DIM Numn2 AS LONG
DIM Numn3 AS SINGLE
DIM Numn4 AS DOUBLE
DIM Header AS STRING
Header = "Another way in declaring variables"
Numn1 = 5
Numn2 = 5600
Numn3 = 45.7
Numn4 = 6600.78
PRINT Header
PRINT Numn1 + Numn2 + Numn3 + Numn4
Here, we declared each variable using DIM and assigned them different data types.
When the program runs, it prints the header and then calculates the total of all the numbers.
DIM Numn1 AS INTEGER
DIM Numn2 AS LONG
DIM Numn3 AS SINGLE
DIM Numn4 AS DOUBLE
DIM Header AS STRING
Header = "Another way in declaring variables"
Numn1 = 5
Numn2 = 5600
Numn3 = 45.7
Numn4 = 6600.78
PRINT Header
PRINT Numn1; "+"; Numn2; "+"; Numn3; "+"; Numn4; "="; Numn1 + Numn2 + Numn3 + Numn4
This example prints the expression and the result together, helping you visualize both the operation and its output clearly.
Using DIM with AS makes your QBasic programs neat, readable, and more professional. It also helps prevent data type errors and improves program structure.