0

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 introduced as a reference in the project. Now the compiler thinks that state is referring to a global variable in the DLL. Now a line in the code causes a type mismatch error.

How can I avoid this problem?

Ref: http://msdn.microsoft.com/en-us/library/aa241733(v=vs.60).aspx

CJ7
  • 22,579
  • 65
  • 193
  • 321
  • 1
    `Dim` that `state` in the procedure. No other way. – GSerg Jan 11 '13 at 12:13
  • Ok, but there many other procedures like this - will be very time consuming if that is the only way. The other thing is that even if there is a control on a form with the same name, the DLL variable takes precedence. – CJ7 Jan 11 '13 at 12:35
  • Yep. Or remove the reference to the dll. – GSerg Jan 11 '13 at 12:37

1 Answers1

0

If it is not too much of a bother, you can make another project as a wrapper around the dll, and only expose what you need. Your VB6 program should reference the wrapper instead of the original dll. If you need the global state from it, you can rename it. If not just hide it.

djv
  • 15,168
  • 7
  • 48
  • 72