Assignment statement syntax revisited

In our earlier note on the syntax of assignment statements, we saw that they have the general form:

   <left hand side> = <value>

Where a value from the right hand side is assigned to the left hand side.

The first use of the assignment statement we saw was assigning new values to properties of objects, for example:

lblName.text = "Bob Smith"

Next, we learned about variables, and saw that one can also assign a new value to a variable, for example:

intAge=18

The same pattern applies for object variables. The value of a property can be an object, for example:

lblGreeting.font = bigFont  (where bigFont is an object variable)

We can also assign new values to object variables, for example:

bigFont = New Font("microsoft sans serif", 48) (where bigFont is an object variable)

The pattern is the same with each of these variations on the assignment statement. An equal sign separates the left and right parts of the assignment statement, and when it is executed, the value of the right-hand side is assigned to whatever is named on the left. In all cases, the left and right-hand data types must be compatible.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.