INPUT 'What is your age', age When a semicolon (;) is used after the text output to the user, a question mark (?) and 'space' are added to the output. When a comma (,) is used no question mark is added. If a string is specified (eg 'name$'), anything the user enters before pressing the 'return' key will be accepted. If a numeric variable (eg 'age') is specified, the user must enter a number (if any non-numeric key is entered, the error message 'Redo from start' will be output and the INPUT command rerun) 6INPUT.BAS. 1 CLS 2 INPUT 'What is your name'; name$ 3 PRINT 'Hello, '; name$; '!'
4 INPUT 'How old are you'; age 5 INPUT 'what is your best computer game?' , game$ 6 PRINT ' name:'; name$ 7 PRINT ' age:'; age; ' years old' 8 PRINT 'best game:'; game$ Please note: In the PRINT command, the (;) function concatenates (joins) the contents of the string variables with the text between the quotes (' '). Note the use of spaces so that the final printed text reads properly. If a numerical variables is specified within the PRINT command, an additional space is automatically added both before and after the number. See also: LINE INPUT command to read a line of text from a file (and place the result in a string variable) or to input a series of variables (in which case any commas found will be treated as delimiters between fields). Text Output Text Output Your first QBasic program: 1HELLO.BAS The following paragraph requires a computer with QBasic installed To begin, copy everything from the program below ('PRINT 'Hello World') into a text editor or into the QBasic IDE (Integrated Development Interface) itself and save it as '1HELLO.BAS'. Next open the file in QBasic (unless you used QBasic IDE in which case it is already open) and press F5.
Optionally you can use the 'RUN' menu located on the menu bar at the top of the IDE window. This will execute (run) the program. The words 'Hello World' should appear on the upper left hand side of the screen. You have just executed your first QBasic program. If you press F5 again, another line of text saying 'Hello World' will appear on the upper left hand side of the screen pushing the first one down to the second row of the screen.
You can follow the same procedure for the rest of the example programs in this wikibook. 1HELLO.BAS. PRINT 'Hello World' PRINT PRINT is QBasic's text output function. It is the command that we will be exploring through this section.
PRINT is a QBasic function that requires arguments. The argument in the Hello World program we just ran were the words 'Hello World'. So, PRINT is the function and 'Hello World' is the argument we pass-to the function.
PRINT Text to screen.note, for a short cut, just use a question mark '?' In place of the command 'PRINT'. Likewise you can use a single quote ' ' ' in place of the key word REM to insert comments in your code 2HELLO.BAS.
Hello World Hello Jupiter Good Bye For Now 1 2 3 4 5 The first line of 2HELLO.BAS outputs 'This line will be erased.' To the screen. However, in the second line, the CLS command clears the screen immediately after. So, it will only flash momentarily. The text 'Hello Jupiter' should line up with '2' under it.
I know how to make and sell software online, and I can share my tips with you. Email| Twitter| LinkedIn| Comics| All articles How QBASIC almost got me killed.
More than one comma can be used consecutively. In this example, after 'Good Bye' two commas are used to move 'For Now' over two tab columns.
'For Now' should line up with '3'. My final statement on this topic is to play around with it. Try using commas and semicolons in a program. 3HELLO.BAS. CLS hello$ = 'Hello World' number = 12 PRINT hello$, number Variables Variables are used to store information.
They are like containers. You can put information in them and later change the information to something else. In this first example they may not seem very useful but in the next section (Input) they will become very useful. In this example we use two types of variables - string variables and numeric variables. A string variable holds words, a string of characters (a character is a number, letter or symbol). In this case the characters are letters.
A string variable is denoted by ending the name of the variable with a dollar sign. The string variable in this program is hello$. What ever you set hello$ equal to will be displayed in the PRINT statement. The numeric variable is number. Numeric variables do not have a special ending like string variables.
4FACE.BAS. CLS LOCATE 14, 34 'position the left eye PRINT ' 'draw the left eye LOCATE 14, 43 'position the right eye PRINT ' 'draw the right eye LOCATE 16, 39 'position the nose PRINT 'o o' 'draw the nose LOCATE 18, 36 'position the mouth PRINT ' /' 'draw the mouth LOCATE 19, 42 'the bottom PRINT 'The Face by QBasic' LOCATE statement LOCATE allows you to position the cursor for the next piece of text output. Contrary to Cartesian coordinates which read (X,Y), the locate statement is LOCATE Y,X. In this case Y is the distance down from the top of the screen and X is the distance from the left side of the screen. The reason that LOCATE does not follow the standard coordinate system is that it is not necessary to include the X portion, you can use the format LOCATE Y which just specifies the line to start on.
LOCATErow,column LOCATErow 5FACE.BAS. CLS LOCATE 14, 34 COLOR 9 PRINT ' LOCATE 14, 43 PRINT ' COLOR 11 LOCATE 16, 39 PRINT 'o o' COLOR 4 LOCATE 18, 36 PRINT ' /' COLOR 20 LOCATE 19, 42 PRINT 'U' LOCATE 1, 1 COLOR 16, 1 PRINT 'Hello World' COLOR statement The program 5FACE.BAS is broken into sections to make it easier to read.
This is an example of a good programming habit. Each three line piece of code each piece of code specifies what color it's part of the face should be, where it should be and what it should look like. The order of the position and the color is unimportant. The new statement COLOR allows you to change the color of the text.
Once changed, all output will be in the new color until COLOR or CLS is used. COLOR foreground COLOR foreground,background The colors are designated by numbers which will be discussed in the next section. Color by Number There are 16 colors (in screen mode 0), numbered from 0 to 15. 0 Black 8 Dark Grey (Light Black) 1 Blue 9 Light Blue 2 Green 10 Light Green 3 Cyan 11 Light Cyan 4 Red 12 Light Red 5 Purple 13 Light Purple 6 Brown/Orange 14 Yellow (Light Orange) 7 Light Grey (White) 15 White (Light White) If you look carefully at this chart you can see that there are 8 main colors (0 through 7) and then those colors repeat, each in a lighter shade.
You may also notice that the colors act as a combination of binary values (where blue=1, green=2, red=4, etc.) This makes it much easier to memorize the color scheme. Blinking colors are also available: at 16, the colors start over again with blinking black and extend through 31 (blinking white). However, the blinking option is not available for the background, only for the text (foreground). Add 16 to the color you wish to blink. Eg: 2+16=18 - Blinking Green, 4+16=20 - Blinking Red. It is possible to switch the blinking foreground text with an intense background, but this task is beyond the scope of this QBasic textbook, and may not work when MS Windows displays the console in a windowed mode. Summary In this section we looked at several methods to manipulate text output.
All centered around the PRINT statement. LOCATE and COLOR modified where the text was displayed and how it looked. We used CLS to clear the screen and gave a brief introduction to variables which will be expanded upon in later sections.
Basic Math There are six numerical variables within QBasic: Type Minimum Maximum Integer -32,768 32,767 Long Integer -2,147,483,648 2,147,483,647 Float -3.37x10^38 3.37x10^38 Double -1.67x10^308 1.67x10^308 64-bit Integer -9,223,372,036,854,775,808 9,223,372,036,854,775,807 64-bit Float ±1.18E−4932 ±1.18E+4932 Please note that Integer and Float type variables for 64-bit are available only in QB64. A lot of programming is math. Don't let this scare you: a lot of the math is simple, but it's still math. In this section, we will look at doing some basic math (the same stuff you learned in the 3rd grade) and manipulating numbers.
Equation Setup In QBasic an equation has a basic setup a right side and a left side. For instance X=5, as you can probably figure out, this sets the variable X to 5. But we can use variables on the right side too. Y=X.10 would set Y equal to 10 times X, in this situation, 50. In this next program I will show several equations to give you a feel for math. 7MATH.BAS.
CLS 'Set a-d to initial values a = 10 b = 6 c = 3.1415 d = 3.333333 e = a + b PRINT a; '+'; b; '='; e f = c. d PRINT c; '.' ; d; '='; f g = b - c PRINT b; '-'; c; '='; g h = b / d PRINT b; '/'; d; '='; h i = INT ( d ) PRINT 'Remove the decimal from '; d; '='; i Understanding 7MATH.BAS The most important thing you can take away from this is the setup for math equations. I think you can figure out what all the symbols are and what they do, but QBasic is picky about equations. For 'e=a+b', if you try 'a+b=e' it will not work.
The final thing I would like to address in 7MATH.BAS is the INT function. As far as vocabulary, a function is something that takes in a piece of information and gives you another piece of information back.
So PRINT, was a statement, and INT is a function. The INT function takes a number and truncates it's decimal, it does not round. So INT(5.1) is 5 and INT(5.999) is still 5. If you want to round a number use CINT. 8MATH.BAS. CLS INPUT 'Enter a number: ', x PRINT x = x + 5 PRINT 'X is now: '; x x = x.
![Edit Edit](http://www.petesqbsite.com/sections/introduction/qb45.png)
x PRINT 'X is now: '; x x = x / 5 PRINT 'X is now: '; x x = x - 4 PRINT 'X is now: '; x x = x / x PRINT 'X should be 1: '; x Understanding 8MATH.BAS 8MATH.BAS shows one simple concept that is very important in programming, but impossible in math. The way that the computer calculates the equation is it does all the math on the right side of the equation and then sticks it in the variable on the left side. So the equation x=x+5 makes perfect sense, unlike math where it is a contradiction. Reassigning a value to a variable based on its current value is common and a good way to keep the number of variables down.
9TIP.BAS. CLS INPUT 'How much is your bill: ', bill INPUT 'What percent tip do you want to give: ', tip tip = tip / 100 'change percent to decimal tip = tip. bill 'change decimal to money PRINT PRINT 'The tip is'; tip; '$.' PRINT 'Pay'; tip + bill; '$ total.'
Tip Calculator 9TIP.BAS calculates your tip and total bill from the bill and percent tip you wish to give. The first three lines clear the screen and get the information from the user.
The fifth line changes the tip from a percent to the correct decimal by dividing by 100 (ex. 20%=.2 because 20/100=.2) the next line takes that percent and turns it into a dollar value by multiplying the decimal value by the bill. So if your bill is $20.00 and you leave a 20% tip, it multiplies 20.2 which is 4 or $4.00. The last three lines format the output. This is a good example of a complete program.
It collects information from the user, it processes the information and it gives the user feedback. Also, the middle section of the program is a good example of variable conservation. This is subject that will take some practice to get used to. In writing a program, if you use too many variables, it will become difficult to keep track of all of them. If you try and conserve too much, you code may become difficult to understand. You may notice that the program may print more than two decimal places if you enter a bill that is not an exact dollar value. As an exercise, try modifying the program so that it only displays two decimal places - you can use the CINT function or any other rounding method you intend to use.
10OROP.BAS. 'ORder of OPerations CLS a = 15 b = 10 c = 12.2 d = 1.618 PRINT a. b + c 'these two are different PRINT a. ( b + c ) PRINT PRINT b - c / d 'these two are different PRINT ( b - c ) / d PRINT PRINT a.
b - c. d / a + d 'these two are the same PRINT ( a.
b ) - (( c. d ) / a ) + d Parentheses and Order of Operations 10OROP.BAS is an example of order of operations and how parentheses can be used to manipulate it. I do not want to go into an indepth explanation of the order of operations here. The best advice I can give is unless you are sure of the order of operations, use parentheses to make sure the equation works how you want. All you need to know about parentheses is that the deepest nested parentheses calculate first. If you wish to know more, there are plenty of algebra resources available.
On that note, you may wish to brush up on algebra. While it is not necessary for programming, it can help make programming easier and it can allow you to create more advanced programs. Random Numbers Though we will not go into their use until the next section, I would like to discuss the generation of random numbers. QBasic has a random number statement, RND, that generates a random decimal between 0 and 1. You can think of it as a random percent. At first, this may seem like an odd way to generate random numbers.
However, with a little math it is very easy to manipulate this to provide numbers in whatever range you want. The first step is to multiply RND by a number (the range you want). For instance 'RND.10'.
This will return random numbers (decimal numbers) between 0 and 10(both included). So, to pick a random number between zero and ten we would say '(RND.10)' 11RND.BAS. CLS RANDOMIZE TIMER PRINT 'Random number from 0-9:'; RND. 10 PRINT PRINT 'Random number from 1-10:'; ( RND.
10 ) + 1 PRINT PRINT 'Random integer from 1-10:'; INT ( RND. 10 ) + 1 PRINT PRINT 'Random even integer from 50-100:'; INT ( RND. 25 ). 2 + 50 More on RND A few notes on 11RND.BAS, the second line, RANDOMIZE TIMER, sets it so that the computer uses the current time to pick random number.
If you don't do this, it picks the same random number every time (try it, write a one line program, PRINT RND, and run it over and over, your screen will fill up with the same number) this can prove useful for some applications, but not most. Stick RANDOMIZE TIMER in at the top of all your programs that use the RND statement and they will be far less predictable. This program just show some ways to choose what you want from your random number generator.
The last line shows that you can be very specific in what you get. Make sure to run this program several times to see the different results. Flow Control Conditional execution To choose between two or more sections of the program to execute, the IF statement can be used. It is also possible to use the WHILE, DO UNTIL and CASE statements. All of these control conditional execution by using a Boolean logic 'test', the result of which is either TRUE or FALSE.
To repeat a section of code for a set number of times, the FOR statement is used. The IF test can be executed in a single line, however it can also be used like the others to control a block of code. True or False Boolean logic is a test that yields one of only two possible results, true or false.
The tests are always mathematical in nature. When two characters (or strings) are 'compared' it is their ASCII codes that are used (thus a true if the first is greater than the second = true if the first is greater than or equal to the second true if the two are unequal Multiple tests can be linked together in the comparison, using the 'AND', 'OR' and 'NOT' operators.
We will cover exactly what these mean later on, but you probably understand the first two already. IF One of the most useful statements in QBasic is the IF statement. It allows you to choose what your program will do depending on the conditions you give it. The next few programs will be taking a look at ways to use the IF statement. IF conditional THEN do this The single line IF is the simplest example.
![Windows Windows](/uploads/1/2/5/3/125380727/656676425.jpg)
To execute a block of code, the END IF is used IF conditional THEN do this and do this. and also do this END IF IF.THEN.ELSE IF conditional THEN do this ELSE do that To choose between two different code blocks, the ELSE statement is used. IF conditional THEN do this.
and do this ELSE do that. and also that END IF 13 ELSEIF As an alternative to starting an entirely new IF THEN ELSE statement sequence. You can follow the THEN statement(s) with ELSEIF conditional THEN.
This does not create a new level of nesting. IF conditional THEN do this.
and do this ELSEIF conditional THEN do that. and also that ELSEIF conditional THEN do the other. and also. ELSE do this final thing END IF FOR.NEXT FOR = TO STEP do this. and do this NEXT may be + or - and is optional. If omitted the default is +1.
The code contained within the FOR loop will always be executed at least once because it is only at the 'NEXT' statement that the value of the variable is checked against the end value. When the NEXT statement executes, the variable is modified by STEP value and compared against the end value.
If the variable has not yet exceeded the end value, control is returned to the line following the FOR. You can exit a FOR loop early with the EXIT FOR command. 14FOR.BAS.
CLS RANDOMIZE TIMER num = INT ( RND. 20 ) + 1 FOR count = 1 TO 5 INPUT 'Pick a number between 1 and 20: ', answer IF answer = num THEN PRINT 'You win after'; count; 'guesses!' : END NEXT PRINT 'You lose' WHILE.WEND WHILE do this. and this WEND If the condition is true, the code following the WHILE is executed. When the WEND command is executed, it returns control to the WHILE statement (where the condition is tested again).
When the condition evaluates to FALSE, control is passed to the statement following the WEND. 15WHILE.BAS. PRINT 'Press any key to continue' WHILE INKEY$ = ' WEND In the example above, you see a press any key prompt that waits until the user presses a key. (The INKEY$ feature will be described under.) DO.LOOP DO this.
and this LOOP WHILE / LOOP UNTIL The DO.LOOP construct is a more advanced of the WHILE loop - as with other flow control blocks, it is marked by DO and LOOP to denote the boundaries. It relies on a conditional statement placed after either DO or LOOP. CLS RANDOMIZE TIMER num = INT ( RND.
100 ) + 1 DO INPUT 'Pick a number between 1 and 100: ', answer IF num = answer THEN PRINT 'You Got It!' IF num answer THEN PRINT 'Too Small' IF num CASE do this CASE do instead. END SELECT The select statement is a substitute for repeated use of IF statements. The is evaluated and compared against each CASE in turn. When a CASE is found to match, the do this code following is executed. If an EXIT CASE is executed, control passes to the line following the END SELECT, otherwise the next CASE is checked.
If no matches are found, the CASE ELSE is executed. Note that may be a number, character or string or logical expression (eg '0', '1'). Note also that multiple CASE matches may be found and executed (so, for example, if two CASE are 'CASE 1' and 'CASE 10', a that evaluates to 11 (or more) will result in both CASE 1 and CASE 10 being executed). CLS PRINT 'WELCOME' PRINT 'I HAVE AN ANSWER FOR ANY OF YOUR QUESTIONS' 10 INPUT 'WRITE YOUR QUESTION AND I'LL GIVE YOU AN ANSWER ', question$ RANDOMIZE TIMER PRINT answer = INT ( RND. 4 + 1 ) SELECT CASE answer CASE 1 PRINT 'PLEASE REPHRASE YOUR QUESTION.' CASE 2 PRINT 'YOUR QUESTION IS MEANINGLESS.' CASE 3 PRINT 'DO YOU THINK I CAN ANSWER THIS?'
CASE 4 PRINT 'THIS QUESTION LOOKS FUNNY.' END SELECT PRINT PRINT 'ENTER ANOTHER QUESTION', K$ GOTO 10 If a parameter would be covered by more than one case statement, the first option will take priority. Advanced Input INKEY$ Getting real time information from the user is a little more difficult. To do so, we will use the INKEY$ command, which checks to see if a user typed a key and provides the keypress to the program. Look at this code and then we will look at it in depth: DO LET k$ = INKEY$ LOOP UNTIL k$ ' SELECT CASE k$ CASE 'q' QuitProgram CASE 'c' MakeCircle CASE 's' MakeSquare END SELECT The first part is the DO-LOOP which constantly polls INKEY$ for a return value. In the basic use, INKEY$ returns an empty string if no keys are being pressed and continues with the program. Once a key is pressed, INKEY$ will return that key immediately.
The keyboard buffer What is INKEY$ doing and how does it work? While the INKEY$ command looks like it returns the key currently being pressed, this is not the case. It is used by the program to answer the question, 'What is IN the KEYboard buffer?' To understand this you will need to understand what a basic buffer is and why it is used.
In older systems (not necessarily the IBM PC) a single chip processed keyboard input, and controlled the LED lights for caps lock and number lock. Because a computer does many things at once (e.g., take input from the mouse, crunch numbers, call subroutines, display new information on the screen), it needs to be able to remember what was pressed on the keyboard while it is busy. This chip contained some memory (called a buffer) that allow keeping track of a limited number of keypresses. Within the Dos platform under IBM PCs, the hardware has changed slightly. Instead of a hardware buffer, pressing or releasing a key will interrupt the running program to add a keystroke to a software buffer located in the BIOS. This procedure is usually unnoticed by the user and has minimal impact on system performance. However, this buffer allows for 15 characters - attempting to overflow it when the computer is busy will cause a short beep and drop any further characters.
The INKEY$ command uses this buffer as a FIFO (First In First Out) buffer. As an example let's say you have a game that has a bouncing ball on the screen and a paddle at the bottom. The computer program constantly has to update the screen to show the movement of the ball. While it does this the program passes by an INKEY$ command to see what value is returned.
If the user has pressed a key since the last time the command was invoked it will return that key. Let's say the ball is moving over to the right and the user needs to press the 'R' key to tell the program to move the paddle right. Since the program is busy moving the ball and updating the screen, it does not instantaneously notice that the user has pressed the key. Instead, the key press is stored in the keyboard buffer, and retrieved a few milliseconds (or microseconds) later when the INKEY$ command is used. In many programs (as above), INKEY$ will appear nested in a loop. It is requested over and over again. This allows the program to get user input one character at a time.
Using our example above, the user may need to press R over and over again until the paddle is under the ball. On the other hand, the user may press R too many times and need to press L to move it left. Because the INKEY$ command is using a FIFO buffer it will always retrieve the keys pressed in the same order as they were typed. In summary, the INKEY$ command will always return and remove the first character in the keyboard buffer. Generally speaking, it is used over and over to retrieve every key that has been pressed, and to allow a user to interact with a program in a close approximation to 'real time.' If there is no key in the keyboard buffer, INKEY$ it will return an empty string (no character).
Scancodes Some keypresses are not associated with an ASCII character. When one of these keys is pressed, INKEY$ returns a string with two characters = the first character is a null (ASCII code 0), and the second is the raw scan code for the keyboard. A full listing of the scancodes can be found within the QBASIC help file - you can also determine the scan codes by examining the results of INKEY$ as you press those keys in question. Note: Some keys cannot be directly detected by INKEY$.
Subroutines and Functions Purpose Subroutines and functions are ways to break up your code into reusable 'lumps'. They allow the programmer reuse a large set of common instructions just by calling the appropriate procedure or function.
For example, lets say you need to PRINT multiple Tables of values. One way to do this is to just enter all the Table PRINT commands directly into where you need them. However this not only makes the program very large but also makes it harder to debug or change the 'style' of the table.
A simpler way is to create a single 'Print Table' procedure and enter all of the PRINT commands there. Then, each time need to print a Table, you would simply 'call' the 'Print Table' procedure with a list of the values to be printed. Procedure vs. Function A procedure does something and does not return anything for the programmer. For example, a procedure might be used to set the screen mode and palette. A function does something and RETURNS a value.
For example, if you need to find the average of two values, you might write a function that takes in two numbers and returns the average. GOTO and GOSUB The GOTO and GOSUB statements were the original methods by which functions were created. They were the most common on older basic implementations and are kept around for compatibility reasons; however, their use is not recommended in other programming languages or in large scale projects, both because GOTO's make it harder to 'follow' the program flow and because GOSUB's do not 'isolate' the changes made to any variables. These two commands depend on Labels, which come in one of two forms.
The first and older form involves writing line numbers at the beginning of each line (usually in increments of 10). The newer method looks similar to other programming languages, which is a single word followed by a colon.
The GOTO statement is simple; it just moves the execution point to a given Label. ON ERROR The ON ERROR allows you to define an error handler for your program; when an error occurs, it immediately jumps to the given label.
The control returns once the program reaches a RESUME statement, which can either return control to the same point, the next statement, or any other desired label. Within Qbasic, the error handler cannot be located within any subroutines. As such, any error checking or flags will have to be handled through the use of variables that are shared with the main module. Note: While the QBasic documentation states ON ERROR RESUME NEXT is a valid statement, this is incorrect. NOTE: If your error handling routine does not have a 'resume' statement in it (IOW you try to do it all with gotos) error handling will only work once - the next 'on error' will be ignored and the program ends as if you had no 'on error' statement at all. This problem does not seem to be mentioned in any of the documentation.
It took me three hours to figure out why two nearly identical program portions acted so differently. Declaring a subroutine A superior method of declaring a subroutine is using the SUB statement block, because (by default) any new variables used within the subroutine are discarded on exit. Under the QBasic IDE, doing so moves the SUB block to its own section in the window to prevent accidental deletion of the module, and allows the easier organization of the program code. Calling a subroutine is as simple as writing the name of the subroutine (passing any required parameters). If you want, you can use the CALL statement to indicate to other programmers that it is a subroutine. FUNCTION name ( params ) ' Shared variable declarations name = result '. END FUNCTION Functions are declared in the same way as variables - it returns the variable type it's defined to return, in the same way variables are defined to contain their specified type.
By default, it is a number, but appending a dollar sign indicates that it is returning a string. Functions can only be called within an expression; unlike subroutines, they are not a standalone statement. Arrays and Types Q basic is an IDE(integrated development environment) developed by Microsoft to create, edit, debug and execute basic program.
Built-in Types QBasic has five built-in types: INTEGER (%), LONG(&) integer, SINGLE(!) float, DOUBLE(#) float and STRING($). QB64 has two more built-in types: INTEGER64 (&&) and FLOAT (##) Implicit declaration is by adding the type character to the end of the variable name (%, &,!, #, $, &&, ##).
See for more. Explict declaration is by using the DIM statement before first use. DIM playername AS playertype playername. Name = 'Bob' playername. Score = 92 This above example shows how a custom type can be used for maintaining data, say on a player who plays a game. Array An array is a collection of values stored in a single variable.
A STRING is an array of characters (so, for example, char$(1) means 1st character in string char$). Arrays of numbers should be defined using the DIM instruction (unless you DIM them, they are limited to 10 elements on each dimension).
By default, arrays in QBasic are static in size and cannot be changed later in the program. Code that will set up this type of array is as follows. DIM myArray ( 10 ) as TYPE 'this is explaining the datatype to be used during program execution in array' TYPE can be any of the built in QBasic (INTEGER, LONG, SINGLE, DOUBLE, STRING) or user-defined type. If this is not specified, the array takes the Type defined by the variable name suffix - INTEGER (%), LONG(&) integer, SINGLE(!) float, DOUBLE(#), STRING($) - or INTEGER if none. WARNING: If your data Type is string, DIM string(10) defines a SINGLE string of 10 characters, NOT 10 strings of arbitary length! (10 strings of up to 128 chars each would be defined as DIM string(10,128) By issuing the Meta Command '$DYNAMIC at the beginning of your program you can cause your arrays to be dynamic.