Chapter 3 – Fundamental Statements QBasic Chapter 3 – Fundamental Statements
QBasic Statement Components Keywords Constants Numeric constants Real numbers – include decimal points Integers – w/out decimal points No commas, symbols (only – sign) or blank spaces Exponential notation is used
QBasic Statement Components Constants Character string constants Alphanumeric data Only one set of double quotes Length of a string – max 32,767 characters Variables Can only store one value at a time Referred to by addresses Variables are named Only first 40 characters are recognized in QBasic QBasic does not differentiate between upper & lowercase Use descriptive variable names
QBasic Statement Components Numeric Variables Supplied by the programmer or Calculated during program execution Begins with a letter, followed by letters, digits, and periods Cannot have blank spaces
QBasic Statement Components String Variables Stores character strings Begins with a letter followed by letters or digits and always end with a $ Keywords Cannot be used as variable names READ, LIST, PRINT, LET and END
Simple QBasic Statements CLS – Clear Screen Documenting a Program REM Single quotation mark (‘) Can be used anywhere in the program REM **** This program was created by *** ‘ This program was created by
Simple QBasic Statements Assigning Values to Variables Assignment Statement LET keyword is optional LET Rate = .0825 LET Tuition = 50.00 Heading$ = “Inventory Report” Classification = 4
Simple QBasic Statements Arithmetic Operations Composed of numeric constants, numeric variables, and arithmetic operators +, -, /, *, ^ LET Tuition = Hours * 50 Order of Operations - PEMDAS
Simple QBasic Statements Displaying Results PRINT PRINT Heading$, Tuition would result in: Your tuition amount is 400.00 Displaying Literals Group of characters containing just about anything PRINT “JUNK $%^ 4567” would result in: JUNK $%^ 4567
Simple QBasic Statements END Stops program execution Immediate Window Execute statements as soon as ENTER is pressed
Simple QBasic Statements HELP F1 key or HELP menu Highlight menu option & then press F1 or right mouse button Press ESC to close HELP screen Alt-H for list of HELP topics Smart Editor