Assignment Statements (Let, Set)

Language Items List

Definition:

The optional assignment keywords, Let and Set, assign a value or object reference to a variable, respectively. The use of these keywords is optional and has no effect on the assignment statement, either in terms of what is allowed for the variable being assigned to or the value it is given.

Syntax (1):

[Let | Set]variable = {expression | Nothing}

Syntax (2):

Syntax Description


Let Optional keyword.

Set
Optional keyword.

expression Value assigned to variable. When used to assign an object reference, expression must be an object of a type that is consistent with the object reference variable to which it is assigned. This means expression must be of the same type as the variable or a derived type. An example of a derived type is
Form is a derived type of Window. In this example, an Object reference variable that is of type Window could accept objects of type Window, Form, or any other type derived from Window.

Nothing Reserved word that discontinues association of variable with any specific object. This is a special value that means
no object.

Details:

The reserved words Let and Set are optional and seldom used since you can assign a String or numeric expression to a variable without using them.

The value expression and the variable or property should have compatible data types. This means that in most cases you cannot assign a value of type String to a variable or property of type Numeric or vice-versa, or a type mismatch program exception may be thrown. In some cases, if a string expression holds a number such as "123" it can be converted to an integer, and vice -versa. The expression
123 & 45 would yield the string 12345.

If the value expression and the variable or property have different but compatible data types, Phoenix usually converts the value to the type of the named variable or property. For example, if the expression is Long and the receiving variable is an Integer, it is converted to Integer, the numeric data type of the named variable. There are some exceptions as mentioned in the previous paragraph.

See Also:

= Operator

:= Operator

Const Statement