Differences Between Properties and Variables

Variables and properties let you get access to values. But there are differences in their storage and implementation.

Variables

A variable always has a location in memory. You make a variable with one declaration statement. You make a local variable in a procedure, and it is available only in that procedure. You make a member variable (also known as a field) in a module, Class, or Struct.

Properties

A property is a data element that you make in one of the containers Library or Class. You make a property with a code block between the clauses Property and End. The code block contains procedures: Get, Set, or the two together. These procedures are known as property procedures or property accessors. They not only return and store a property's value, but can also do other operations.

Differences

Quality Variable One-line property Block property
Declaration One declaration statement One declaration statement Sequence of statements in a code block
Implementation One location in memory One location in memory Executable code.
Storage Directly related to its value Directly related to its value By default, has storage local to the property.
Executable code None None One or two procedures
Read and write access Read/write or read-only Read/write Read/write, read-only, or write-only
Special operations (more than a result or a changed value) Not possible Not possible Possible with Get and Set.

See also