Implicit declaration isn't good practice. It allows you not to dim variables in advance and just introduce them as and when necessary in the code. The disadvantages are:
- They will be Variant data type which occupies 16 bytes and is wasteful.
- It's easy to mistype a variable name later in the code. It won't cause any compile errors but will have a value of Empty at run-time, when you are expecting the value in the correctly spelt variable
I would always use Option Explicit to force explicit declaration. It leads to many good coding practices such as declaring all variables at the start of the procedure, prefixing the variable name to identify the data type and commenting the purpose of the variable.
Option Explicit provides compile-time checking for mistyped names and data type mismatches.
I see. Explicit is using a Dim to specify the variable type while implicit is a variable without a Dim specification that the process allocates as a variant.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.