Back to lesson
1. If your variable's data type is not set in the Dim statement, what is the default type applied to the variable when the code begins running?
Whatever is assigned to it
2. What is the best way to ensure that you will always explicitly declare your variables?
Go to the Tools menu, select Options and check the box for Require Variable Declaration
Ensure the words "Option Explicit" are visible at the top of the code module
In the Visual Basic Editor, type Require Variable Declaration at the top of the code module
3. What is wrong with the following line of code? Dim sTitle as String, sBody, wsTarget as Worksheet
sBody is a Variant
The extra variables should be separated with semi-colons (;) not commas
wsTarget is not the same data type as the other two variables
Back to the top
© 2017 GoSkills Ltd.
Skills for career advancement