VBUC 10 unblocks VB6 modernization

by John Browne, on Nov 14, 2023 3:00:00 AM

It's been almost 3 years to the day since the release of VBUC version 9.0, the last BIG update (not to hurt the feelings of all the intermediate ones since). But today we're announcing  VBUC 10.0 is available for everyone to download, and it has a feature a long time in the making that earned that dot zero version number.

VB6 modernization tools upgraded

Prior to today, in order for the VBUC to even attempt a migration of VB6 source code, you had to have a compiling project with all the dependencies registered in the development environment. Say, for example, your VB6 form used an instance of the Microsoft Flexgrid control. The PC you run VBUC on would have to have that same OCX located and registered in Windows on that machine. 

This gets harder and harder as time passes by, especially with very old components and ones from 3rd party (ie not Microsoft) vendors. I have VB6 installed along with MSDN and a bunch of other stuff on a Dell tower PC running Windows XP. And when I say "running" I mean air gapped to keep the Bad Guys out of my network and thus into actual useful machines. Getting all those bits and pieces installed on a Windows 11 machine is challenging to say the least, if not impossible. To further complicate my particular life, I'm running W11 using Parallels on a Mac Studio. Ugh.

Even on one of my still-useful Windows machines (yes, I might have too many laptops), recently trying to run the VBUC I hit that error: dependency not found, and got into a hair pulling festival trying to get the missing OCX registered. 

And I don't have a surplus of hair to pull, frankly.

Want to simplify your migration process? Get started today!

The way it is now

Well, that was then and this is now. With VBUC version 10, if you are missing references we can substitute a type library (*.tlb) file for the actual component. These will get downloaded automagically from the interwebs when you load a project. 

Pros:

  • Unblocks running the VBUC
  • Lets you migrate the project to .NET
  • Saves your hair from hair-pulling festivals.

Cons:

  • We don't have 100% of the vast ecosystem of controls in the database
  • You can't run the app (the type lib isn't the executable, so calls will fail)

How type library substitution works

A lot of the issues in VB6 to .NET modernization has to do with reconciling type information. VB6 was pretty cavalier in how it treated types, especially compared to C#. In order to run a migration, the VBUC has to build a abstract syntax tree of the entire application, which requires some typing information. We're extracting type libraries from known components and exposing them to the tool via an API call behind the scenes. Once the TLB is downloaded, the tool can proceed. You'll see *tlb files in the references list where this happens. Note: if you don't have the reference, and we don't have a TLB, you will still get the missing reference issue. 

VBUC 10 TLB files screenshot

When you migrate with a TLB instead of the actual DLL or OCX, you will get converted code--usually just the same as with the actual component instead. But, of course, you can't instantiate a control with just a type library. You'd need the actual binary for the application to work correctly. 

Nevertheless, this gets you unblocked and some distance down the road.

Watch a quick demo below--best viewed in full screen. 

 

Did I mention .NET 8?

This week is the annual .NET Conference, and in keeping with our historical ties to Microsoft, we always try to release support for the latest and greatest .NET versions when they come out. Keeping with that, we now support .NET 8 in VBUC, which means we can create a .NET 8 project for your migrated app. We still support all .NET Framework versions that are not out of Microsoft support, as well as multiple versions of .NET Core. 

C# 9 Support

C# just keeps getting better and better, but many of the improvements don't lend themselves to auto-magical transformation from VB6. Nevertheless, our intrepid engineering team found a few cool features in C# 9 that we can generate:

  • Discards: sometimes you have to create a variable on the stack that you don't need to hang around, kind of like houseguests after the weekend is over. C# Discards let you toss those useless things onto the trash heap (variables, not guests).
  • Interpolated strings: When you need to build a string out of a bunch of variables, concatenation can syntax can be clumsy and hard to read (realistically can you even ready your own code after a couple of weeks?). Interpolated strings bring some sanity to this problem.
  • Improved pattern matching: C# 9 allows relational operators like <, >, <=, and >= in patterns to make things like complex CASE statements easier to write and read (see above). 

     

These will be generated in projects targeting .NET 5 and newer versions.

Miscellaneous changes

We continue to update all our mappings of properties, methods, and events from not only VB6 standard components (ie Microsoft ones) but the vast third party ecosystem that was VB6's power and glory in the 90s. Of supreme interest to every thinking person is that we've also updated some of our helper classes to help reduce SQL vulnerabilities in migrated code (VB6 predated a lot of the really bad stuff that app-sec experts face today; SQL injection and buffer overloads being Hacker 101-level payloads). And a release wouldn't be any fun without yet more work on dealing with the dreaded GoTo/GoSub nonsense VB6 encouraged. 

You can download the latest VBUC version here, and/or read the release notes. Have fun and keep in touch.

Have questions? Talk to one of our experts today.

Topics:.NETC#VBUC

Comments

Subscribe to Mobilize.Net Blog

More...

More...
FREE CODE ASSESSMENT TOOL