Siebel VB Language Reference > VB Language Reference >

Let (Assignment Statement)

The Let statement is a standard VB statement that assigns an expression to a Basic variable.


[Let] variable = expression



The variable to which a value is to be assigned


The expression containing the value to be assigned to variable


Not applicable


The keyword Let is optional.

The Let statement can be used to assign a value or expression to a variable with a data type of numeric, string, variant, or record variable. You can also use the Let statement to assign to a record field or to an element of an array.

When assigning a value to a numeric or string variable, standard conversion rules apply.

Let differs from Set in that Set assigns a variable to a COM object. For example,

Set o1 = o2 sets the object reference.

Let o1 = o2 sets the value of the default member.


This example uses the Let statement for the variable sum. The subroutine finds an average of 10 golf scores.

Sub Button_Click
      Dim score As Integer
      Dim x, sum
      Dim msgtext
      Let sum = 34
      For x = 1 to 10
         score = 76
         sum = sum + score
      Next x
      msgtext = "Your average is: " & CInt(sum/(x-1))
End Sub

See Also

Const Statement
Lset Statement
Service_InvokeMethod Event

Siebel VB Language Reference