向变量或属性赋值。
语法
variableorproperty = value
部件
variableorproperty
任何可写变量或任何属性。
value
任何文本、常量或表达式。
注解
等号 (=
) 左侧的元素可以是简单的标量变量、属性或数组的元素。 变量或属性不能为 ReadOnly。 运算符 =
将右侧的值赋给其左侧的变量或属性。
注释
运算符 =
也用作比较运算符。 有关详细信息,请参阅 比较运算符。
重载
=
运算符只能作为关系比较运算符重载,而不能作为赋值运算符重载。 有关详细信息,请参阅 运算符过程。
示例:
以下示例演示赋值运算符。 右侧的值分配给左侧的变量。
Dim testInt As Integer
Dim testString As String
Dim testButton As System.Windows.Forms.Button
Dim testObject As Object
testInt = 42
testString = "This is an example of a string literal."
testButton = New System.Windows.Forms.Button()
testObject = testInt
testObject = testString
testObject = testButton