Visual Basic 6 on Windows 7: DBGrid32.ocx Issues
Unfortunately, I’m one of those poor programmers who is forced to maintain some pretty old applications written in Visual Basic 6. Thus, it was imperative to get the IDE working on Windows 7. When I looked into this issue two years ago, I found an informative post covering the basics over at FortyPoundHead. The installation guide works pretty well except you don’t need to turn off UAC first. So here’s a short summary on how to install VB6 on Windows 7.
- Create an empty file in your Windows directory called MSJAVA.DLL. This is to skip the install of this very old MS Java thingy which even requires a reboot.
- Run setup.exe as administrator and install the needed components
- Install the Service Pack 6
- Install the Visual Basic 6.0 Service Pack 6 Cumulative Update
Step 4 is the culprit that breaks your DBGrid. It will cause your DBGrid controls to lose any information like data sources, layout settings, and so on. So before you proceed with step 4, make a backup of %windir%\system32\dbgrid32.ocx. After installing the SP6 Cumulative Update, replace the newly installed DBGrid32.ocx with the backup you’ve created earlier. Now register the OCX via regsvr32. Everything works fine again.
Alright, this is a dirty hack. It’s definitely better to simply get rid of this control or even better yet – upgrade to a newer Version of Visual Basic. If you’re like me and you can’t migrate to a newer version though, it might help you get around this issue until you’ve replaced all the controls. Good luck!