Differences Between Properties and Variables
A variable always has a location in memory. You define a variable with one declaration statement. You define a local variable in a procedure, and it is available only in that procedure. You define a member variable (also called a field) in a module, Class, or Struct.
A property is a data element that you define on a Library module or Class. You define a property with a code block between the clauses Property and End Property. The code block contains a Get procedure, a Set procedure, or the two together. You can refer to these procedures as property procedures or property accessors. These procedures not only return and store a property's value, they can also do other tasks.
- Variable: A single declaration statement.
- Property: Commonly a series of statements in a block of code.
- Variable: A single location in memory.
- Property: Executable code.
- Variable: Directly associated with its value.
- Property: By default, has internal storage not available outside of the property.
- Executable code
- Read and write access
- Variable: Read/write or (for a Const) read-only.
- Property: Read/write, read-only, or write-only.
- Custom actions in addition to getting and setting a value
- Variable: Not possible.
- Property: Can be performed in getter and setter procedures, respectively.