Visual Basic Language Reference  

= Operator

Used to assign a value to a variable or property.

variable = value

Parts

variable
Any variable or any writable property.
value
Any literal, constant, or expression.

Remarks

The name on the left side of the equal sign can be a simple scalar variable, a property, or an element of an array. Properties on the left side of the equal sign can only be those properties that are writable at run time. When used, the value on the right side of the equation is assigned to the variable on the left side of the equation.

Example

This example demonstrates use of the assignment operator. The value on the right side of the expression is assigned to the variable on the left side of the expression.

Dim myInt as Integer
Dim myString as String
Dim myButton as System.Windows.Forms.Button
Dim myObject as Object
myInt = 42
myString = "This is an example of a string literal"
myButton = New System.Windows.Forms.Button()
myObject = myInt
myObject = myString
myObject = myButton

See Also

&= Operator | *= Operator | += Operator | -= Operator | /= Operator | \= Operator | ^= Operator | Assignment Statements