When we declare a variable as an object or custom data type we can access its members in many ways. In the opinion of many, the easier way is to individually “frame” the object fields by the With structure. Instead of dividing the variable and field name by the „points“, it allows us to define a block of commands, enter values by specifying field names, and then closing a block that completes the value assignment process.
VBA language, among other things, allows you to create custom data types. These are structures that allow users to arrange the data in the desired way so that can easily access them, for example, to define records that store person data as a combination of: ID number, name, surname, address, location, phone number and e- mail address. The arranged data thus facilitates batch processing, and are often used in combination with arrays.
Sorting of an array is arranging of its members in a ascending or descending order. This can be achieved in many ways, and in the text that follows you will see one of the variants of the algorithm called Bubble Sort. It works by running two loops and then, depending on their index values, corresponding members of the array are compared. If the condition is met they change places. The procedure is repeated until the comparison is completed, and array sorted.
During program development it’s important to notice which of its parts can be reused and, based on that fact, should create subroutines that will be called within the main program. Subroutines can be functions and procedures. We use the functions by specifying the variable name, followed by equality sign, and then the name of the function with the arguments. We invoke the procedures using the Call command, after which we specify the procedure name with the arguments.
Errors happen! If there is a critical place in the program where we think that an error may occur it is necessary to mark it and further redirect the program flow to the message that should be displayed if it occurs. For managing the program flow, with and without error, we can use the GoTo command. In combination with On Error we get a powerful tool that helps us take the necessary action immediately after the error is detected.