Q(uick)BASIC Statement: LET
Quick View
LET
The expression evaluation statement that assigns the value of an expression to a variable
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- [LET] variable=expression
Description/Parameter(s)
variable | Any variable. Variable names can consist of up to 40 characters and must begin with a letter. Valid characters are A-Z, 0-9, and period (.). |
expression | Any expression that provides a value to assign. |
- Use of the optional LET keyword is not recommended. The variable=expression assignment statement performs the same action with or without LET.
See also:
Syntax
- [LET] variable=expression
Description/Parameter(s)
Notice that the word LET is optional. The equal sign in the statement is enough to inform QuickBASIC that the statement is an assignment statement.
LET statements can be used with record variables only when both variables are the same user-defined type. Use the LSET statement for assigning record variables of different user-defined types.
Examples
This example shows the use of the optional LET keyword.
CLS ' Clear screen
LET D = 12
LET E = 12 - 2
LET F = 12 - 4
LET SUM = D + E + F
PRINT D E F SUM
The following program lines perform the same function, without using the LET keyword.
CLS ' Clear screen
D = 12
E = 12 - 2
F = 12 - 4
SUM = D + E + F
PRINT D E F SUM
Sample Output:
12 10 8 30See also:
Syntax
- [LET] variable=expression
Description/Parameter(s)
- Use of the keyword LET is optional. The equal sign in the statement is enough to inform BASIC that the statement is an assignment statement.
- LET statements can be used with record variables only when both variables are the same user-defined type. Use the LSET statement to assign record variables of different user-defined types.
Examples
This example uses the optional LET statement to assign values to variables.
LET D = 12
LET E = 12 - 2
LET F = 12 - 4
LET SUM = D + E + F
PRINT D; E; F; SUM
The following program lines perform the same function without using the LET keyword.
D = 12
E = 12 - 2
F = 12 - 4
SUM = D + E + F
PRINT D; E; F; SUM
Sample Output:
12 10 8 30See also: