I have run into an issue with my code, as follows:
Option Explicit Off
Option Strict On 'Results in Compiler Error. Expected base or compare or explicit or private
Sub DoSomething()
Dim intOne As Integer 'This line works
intOne = 1 'This line works
Dim intTwo as Integer = 2 'Results in Compiler Error: Expected end of statement
End Sub
My issues are written as comments in the code above.
Even with a completely empty module, I am unable to enable the Option Strict option.
I think the solution is somewhere in Visual Studio's options.
Note: I have manually translated the error messages from German, so please expect a difference between the above and the official English versions.
Option ExplicitandOption Strictmust be set at the very top, followed by anyImportsfollowed by the class itself followed by the methods:This is the same for modules:
If you want to turn these options on or off for the entire project you can do so in the project properties:
Note that the settings in individual files (if any) will take precedence over the default settings set within the project properties.
Have a look at the documentation for more information on setting Option Explicit and Option Strict.