<< Prev        Next >>

ID : 3761

Let

Function

To assign a value to a variable.

Syntax

[Let] variable = formula

Guaranteed Entry

Variable
Designate a variable name to assign.
Formula
Designate a value to be assigned to the specified variable.

Description

A right-hand value is assigned to left-hand variable.

The right-hand value is automatically converted (casted) into left-hand variable data type and then assigned to the variable. An error occurs in case of data type that cannot be automatically converted (casted).

"Let" is optional.

Related Terms

LetP, LetX, LetY, LetZ, LetR, LetRx, LetRy, LetRz, LetO, LetA, LetF, LetJ

Attention

Array variables cannot be assigned even if the elements of both side (right-hand and left-hand) are the same. To assign any values in array, assign a value to an element one by one.

Dim aaa(10) As Integer, bbb(10) As Integer
aaa = bbb 'This will be an error.
For n = LBound(aaa) To UBound(aaa)
	aaa(n) = bbb(n)
Next

Example

'!TITLE "Assignment of Value to Variable"
' Assign the sum of aaa and bbb to aaa
Sub Sample_Let

  Dim aaa As Integer
  Dim bbb As Integer

  aaa = 1
  bbb = 2

  ' Assign the sum of aaa and bbb to aaa
  Let aaa = aaa + bbb

  ' Display "3" on the message output window
  PrintDbg aaa

End Sub

ID : 3761

<< Prev        Next >>