Questions tagged [option-explicit]
8 questions
55
votes
3 answers
What do Option Strict and Option Explicit do?
I saw this post:
Typos… Just use option strict and explicit please.. during one software development project, which I was on as a consultant, they were getting ridiculous amounts of errors everywhere… turned out the developer couldn’t spell and…

yretuta
- 7,963
- 17
- 80
- 151
3
votes
1 answer
Option Strict On disallows late binding with system.array
I have the following code which return wmi information (unknown array)
For Each objMgmt In oquery.Get()
For Each theproperty In objMgmt.Properties
If (TypeOf objMgmt(theproperty.Name) Is System.Array) Then
myrow(theproperty.Name) =…

WilfriedVS
- 416
- 1
- 4
- 13
1
vote
1 answer
VBScript Option Explicit line order (in relation to libraries)
I have a fairly large VB Script project in which the primary script "includes" a number of "libraries" using the standard trick of reading file contents and running ExecuteGlobal on them. Some of the libraries are pretty vast and written by various…

BuvinJ
- 10,221
- 5
- 83
- 96
1
vote
1 answer
Why doesn't compiler error on build?
I am using VB.NET, at the top is
Option Explicit
However why does the compiler not raise an error when I do :-
obj.ThisFunction(Convert.ToInt32(strMessage))
and the function is :-
Function ThisFunction(id as long)
Surely, Int32 is int and int64…

MiscellaneousUser
- 2,915
- 4
- 25
- 44
1
vote
2 answers
I'm not sure what Option explicit means?
Possible Duplicate:
what’s an option strict and explicit?
Is it about case sensitivity? Complete noob here.

phearn
- 11
- 2
0
votes
1 answer
Dim declaration with assignment and Option Strict
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…

SteffenS.
- 9
- 2
0
votes
0 answers
Invalid Cast Exception On One Machine Given Same Assembly & Data
I have encountered an unusual situation where the same code is behaving differently on a particular machine. The program is written in VB.NET and WF4. The workflow XAML is read from a database at runtime and compiled on the fly. I mention this only…

Kevin Brown
- 1
- 2
0
votes
1 answer
DLL variables conflicting with local variables when Option Explicit Off
I am maintaining a VB6 program that does not use Option Explicit. I know this is not a good idea but I did not write the code.
An example of my problem is that one variable called state has been used in a procedure without Dim.
A DLL has since been…

CJ7
- 22,579
- 65
- 193
- 321