LET statement (with Types)  

Purpose

Assign data to a user-defined type variable.

Syntax

[LET] TypeVar = TypeVar

[LET] TypeVar = VARIANT$(VrntVar)

Remarks

Typevar is a user-defined type variable.  In order to perform direct assignment of data from one user-defined type variable to another, they must be dimensioned to the same type.  To assign data between two different types, you should use the TYPE SET statement instead.

The word LET is optional in assignment statements.  It is allowed to provide compatibility BASIC source files written for early versions of BASIC.  In practice, the word LET is very rarely used.

When User-Defined Type data is stored in a variant variable, it may be extracted as in the second syntax example.  The Variant$() function understands that UDT data is stored as a byte string,

To allow easy conversion, PowerBASIC allows a User-Defined Type in a string expression.  The User-Defined Type is simply copied, byte for byte, into the expression.  To assign a string back to a User-Defined Type, you may also use the TYPE SET statement.  Generally speaking, if a UDT is used in a WIDE string expression (Unicode), it will give unpredictable results from the character conversions.

DIM abc as MyType
MyString$ = abc

See also

LET, LET (with Objects), LET (with Variants), TYPE SET, VARIANT$

Example

MyString$ = "This is a test."
LET TempStr$ = MyString$