Loading and Using VB6 Legacy Projects On Win7
Loading and Using VB6 Legacy Projects On Win7
Loading and Using VB6 Legacy Projects On Win7
Recently, I have had to go back to reinstalling Visual Basic 6 on a Windows 7 workstation and trying to do
some development/bug fixes. Specifically, I have been trying to get my dev environment working to debug
some old VB6 OCX projects. After working through some initial lameness with installing VB6 (for example,
it will always try to install an old version of Java on a new Windows machine- you can trick it out of doing
that), I final got VB6/studio installed and could open my old VB6 project. A few more obvious issues after
that, I was down to one error that I couldn't seem to solve.
The Problem
When I opened any of the VB6 projects, I got the same series or errors trying to load the project. I have
included the screen shots in detail here so you know exactly what I am seeing. I went through various
Google and MSDN recommendations but nothing was working and I did not find a solution. Here were the
errors I was getting:
The project finally appeared, but without some of the MS Controls that I had used in the project.
The error log file referred to in the screen shots contained this kind of error in my project (yours will
vary):
Line 12: Class MSComctlLib.Slider of control sldInterval was not a loaded control class.
Line 37: Class MSComctlLib.Slider of control sldCallTimeout was not a loaded control class.
Line 54: Class MSComctlLib.Slider of control sldConnectTimeout was not a loaded control class.
Line 71: Class MSComctlLib.Slider of control sldTimeoutPeriod was not a loaded control class.
Line 88: Class MSComctlLib.Slider of control sldRetryPeriod was not a loaded control class.
The real problem? The Microsoft Visual Basic 6.0 Common Controls ( MSCOMCTL.OCX ) was not properly
registered. OK. No problem, I thought. So, I quickly went to my Windows/SysWow64directory and I
registered it by running:
> regsvr32 mscomctl.ocx
from the command line (as Administrator). Command shell responded that .ocx was registered
successfully. Woohoo!
Only, once I re-loaded the VB6 project, I got the same error as before: "Object library not registered"
So, I thought I might have to force VB6 studio to re-associate with the OCX so I attempted to add the
mscomctl.ocx file to the project via the Components menu in the IDE. No tamales. Response: "Object not
registered". I even tried reinstalling VB6. No dice either. Bummer.
The Resolution
As I said, re-registering the OCX or reinstalling VB6 didn't help.
Back to Google and MSDN. I found a couple articles online that said to re-register the typelib as follows for
Windows 7--
> cd C:\Windows\SysWOW64\
This apparently works on some computers, but on my machine as the "regtlib.exe" executable was not
present in the SysWow64. In fact, that file as an exe does not exist on my machine. After a bit more
searching, I found that the type library registration is now part of .NET framework. I had to use that
equivalent binary inside of one of my installations of .NET to do the task. On my machine, the solution was
as follows:
> cd C:\Windows\SysWOW64\
Once there, I ran the regtlib command from the .net version that is installed (latest) on my machine.
> C:\Windows\SysWOW64]C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12.exe
msdatsrc.tlb
This command ran successfully and now I can open my VB project. Zippidee doooda! Now my VB 6 project
loads successfully.
Since this took me a while, I assumed others may have run into this gauntlet, so I wanted to be sure to
document the fix in case anyone else runs into this