Main Profile

At A Glance

QBasic Tutorial 4 - Variables And Data Types - QB64 Data Types in QBasic: The computer can hold data in memory. The programmer must tell the computer what type of data to hold. This is called a data type. String.........Text and characters????? Example of a String Data Type: This line is an example of a string Integer.......Non-floating-point numbers from -32,768 to 32,767 Examples of an Integer Data Type:? 67, -34, -100, 203, 1022, -1, 0 Long..........Non-floating-point numbers from -2,147,483,648 to 2,147,483,647 Examples of a Long Data Type: 560005, 3, -2, 0, -867000, 14, 8, -10 Single........Floating-point numbers from -3.37x10^38 to 3.37x10^38 Examples of a Single Data Type: 4.3, 25.4567, -35.87, 0.35, -3.14 Double......Floating-point numbers from -1.67x10^308 to 1.67x10^308 Examples of a Double Data Type: 745663.90596, -98.12, 4859903.094491 Note: In QBasic 1.1 The Double may not work properly on some computers. 64 Bit Data Types (QB64 Only): _INTEGER64 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 _FLOAT ±1.18E?4932, ±1.18E+4932 List of QB64 Data Types: Variables: Hold Data In Memory? Are Assigned A Data Type? The Data Can Change Throughout The Program's Operation? The Data Entered Must Be The Same Data Type As Assigned To The Variable Variables are a name that is given to the data. The name must not start with a number or character that is not a letter. Also, the name of the variable must not be a reserved name like PRINT, INPUT, LET, ABS, BEEP, etc. There are two ways to declare a variable in QBasic. The first is to put a data type symbol after the name $ String % Integer & Long ! Single # Double && _INTEGER64 (QB64 Only) ## _FLOAT Examples: MyName$ Num1% Num2! Answer! The second way is the preferred way since Visual Basic uses this method. Becoming accustom to this way will help the transition from QBasic to Visual Basic. DIM is used to make variables of a data type. DIM [Variable Name] As Data Type DIM [Variable Name] AS STRING DIM [Variable Name] AS INTEGER DIM [Variable Name] AS LONG DIM [Variable Name] AS SINGLE DIM [Variable Name] AS DOUBLE DIM [Variable Name] AS _INTEGER64 DIM [Variable Name] AS _FLOAT Examples: DIM MyName AS STRING DIM Num1 AS INTEGER DIM Num2 AS SINGLE DIM Answer AS SINGLE Remember that selecting the right data type for the variable is very important to make the program run properly.
Length: 05:58


Questions about QBasic Tutorial 4 - Variables And Data Types - QB64

Want more info about QBasic Tutorial 4 - Variables And Data Types - QB64? Get free advice from education experts and Noodle community members.

  • Answer