Using Assignment Operators

The assignment operator assigns a value to a variable. In Visual Basic .NET, as in most programming languages, the assignment operator is the equal sign. Here’s a very simple example that uses the assignment operator. It assigns the value 42 to the variable x.

x = 42

The left operand receives the value of the right operand, and must be a single variable name or property. The first statement shown here is valid because it assigns a value to a property. The second is unacceptable because the value on the left isn’t a single variable name or property.

lblTotal.Text = dblTotal
intEcks + 5 = intWye - 3

The right operand can be any literal, variable, expression, or function that returns a value, as in this example:

sngTravelTime ...

Get Faster Smarter Beginning Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.