Let (statement)


[Let] variable = expression


Assigns the result of an expression to a variable.


The use of the word Let is supported for compatibility with other implementations of the Basic Control Engine. Normally, this word is dropped.

When assigning expressions to variables, internal type conversions are performed automatically between any two numeric quantities. Thus, you can freely assign numeric quantities without regard to type conversions. However, it is possible for an overflow error to occur when converting from larger to smaller types. This happens when the larger type contains a numeric quantity that cannot be represented by the smaller type. For example, the following code will produce a runtime error:

  Dim amount As Long
  im quantity As Integer

  amount = 400123  'Assign a value out of range for int.
  quantity = amount  'Attempt to assign to Integer.

When performing an automatic data conversion, underflow is not an error.


Sub Main()
  Let a$ = "This is a string."
  Let b% = 100
  Let c# = 1213.3443
End Sub

See Also

= (keyword); Expression Evaluation (topic).

More information