Operator =[>] (Assign)

Assigns a value to a variable

declare operator Let ( byref lhs as T1, byref rhs as T2 )

lhs = rhs
lhs => rhs (from fbc version 0.90)
or, in the QB dialect,
[ Let ] lhs = rhs
[ Let ] lhs => rhs (from fbc version 0.90)

The variable to assign to.
Any numeric, boolean, string or pointer type.
The value to assign to lhs.
Any type convertible to T2.

This operator assigns the value of its right-hand side operand (rhs) to its left-hand side operand (lhs). The right-hand side operand must be implicitly convertible to the left-hand side type (T1) (for conversion of a boolean to an integer, false or true boolean value becomes 0 or -1 integer value). For example, you cannot assign a numeric value to a string type; to do that, first convert the numeric value to a string using Str or Wstr.
Assignment between arrays is not supported presently.

Avoid confusion with Operator = (Equal), which also uses the '=' symbol.
For this purpose and for solving some cases of ambiguity of the parser (see BYREF (function results)), the alternative symbol '=>' can be used for assignments (in place of '=') from fbc version 0.90 (same as already for the initializers).
Note: the '=>' symbol has been chosen against '<=' (already the operator 'Less Than Or Equal') and ':=' (':' used as statement separator).

This operator can be overloaded for user-defined types as a member Operator using the appropriate syntax.

Dim i As Integer
i = 420    ' <- this is the assignment operator

If  i = 69 Then   '<-this is the equivalence operator
  Print "ERROR: i should equal 420"
  End -1
End If

Print "All is good."
End 0

' compile with -lang fblite or qb

#lang "fblite"

Dim i As Integer
Let i = 300 ' <-alternate syntax

Dialect Differences:
Differences from QB:
See also:
Back to Assignment Operators
Back to Operators
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki

sf.net phatcode