Shared variables retain its value between object invocations.
Say for example you have a window called w_employee and it has a shared value called "ss_name" If you open multiple instances of w_employee, only the FIRST instance creates the shared variable "ss_name". Second and subsequent windows actually share this variable. In other words, the second instance of w_employee immediately sees the value in "ss_name" which was put there by the first instance of w_employee. And, if the second instance changes the value, w_employee sees that new value.
Shared variables can be used to track the number of times an object has been created by incrementing its value in the object constructor event.
Instance variables do not retain values between object invocations: When the object is created, the instance variable is initialized to its default value.
Note:
Shared objects are best avoided as it is difficult to impossible to understand how the variable got to its current state. This makes debugging very difficult.
Say for example you have a window called w_employee and it has a shared value called "ss_name" If you open multiple instances of w_employee, only the FIRST instance creates the shared variable "ss_name". Second and subsequent windows actually share this variable. In other words, the second instance of w_employee immediately sees the value in "ss_name" which was put there by the first instance of w_employee. And, if the second instance changes the value, w_employee sees that new value.
Shared variables can be used to track the number of times an object has been created by incrementing its value in the object constructor event.
Instance variables do not retain values between object invocations: When the object is created, the instance variable is initialized to its default value.
Note:
Shared objects are best avoided as it is difficult to impossible to understand how the variable got to its current state. This makes debugging very difficult.