![]() |
Variable Assignment |
What does it mean?
When a variable is declared, a certain memory address(es) are set aside to store data. When you assign data to that variable, the data is being stored in that memory location that was set-aside.
Examples
| X = 4 | put 4 in the location which is labeled X |
| X = Y *2 | perform the calculation and store assign the result to X |
| X = X +1 | increment X
if X= 10, when you run this line, X will become 11 |
| Name = MyName | Assign the contents of the variable MyName to Name |
| Name = txtName | Assign the contents of the text box to Name |
| Name = "George" | Assign "George" to Name |
| FoundRecord = True | A Boolean variable can be assigned True or False |
| Common mistake | |
| You get the wrong order
in the assignment
e.g. 4 = X this would result in an error e.g. txtName = Name 'would be OK, except you are assigning the contents of Name to the textbox. |
|
| The arrow below shows you the 'direction' of assignment |
