Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
= Operator

= 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

Show:
© 2015 Microsoft