Qbasic Tutorial for beginners and children (Under Construction)

Declaring variables

BASIC has received many critics because of its ability of creating & declaring variables on the fly. Qbasic allow you to declare variables.

The DIM statement is used to specify a data type for a variable. Variables declared should not end with a suffix.

The syntax is as follows:

DIM variable AS type



DIM userrname AS STRING


username = "John Smith"

age = 23

The code above is equivalent to

username$ = "John Smith"

age% = 23

So what method of working with variables is better? 

Personally, though you might encounter both ways in the tutorial, I prefer to use the first one. It's a good habit to declare every variable you use.

[ Previous Index Next ]

pages viewed since January  19 2002