Constants.(Microsoft Excel Office Scripts)
This section introduces the use of constants in Office scripts.
Constants are like boxes in which data is temporarily stored.
Unlike variables, the value cannot be changed after declaration and initialization.
For example, it is a value that can be named, such as commission rate or sales tax rate.
It is better to use constants, especially for values that appear several times in a program.
Even if a value appears only once, it is easier to read the code if it is a constant.
Declaration and initialization of constants
To use constants, they must be initialized at the same time they are declared.
To do so, use the following syntax (Red text should be modified accordingly)
const constant name: data type = value;
Data types are the same as for variables.
Constants are not available without initialization.
Constants cannot be changed in subsequent programs, though, However, they can be assigned to other variables.
The contents of the variable (valStr) to which the constant (constStr) is assigned can then be changed.
The content of the original constant (constStr) remains unchanged.
For arrays, readonly is used.
For those who want to learn Office scripting effectively
The information on this site is now available in an easy-to-read e-book format for $3.00.
Or Kindle Unlimited (unlimited reading).
You willl discover how to about basic operations.
By the end of this book, you will be equipped with the knowledge you need to use Excel Office Scripts to streamline your workflow.