I'm excited to share our new VBUC release which is gonna knock your socks off - especially all you C# folks! We've been busy behind the scenes pushing some serious upgrades when it comes to migrating VB6 to C#, making your C# code slicker and more efficient. Without belaboring too long, let's get to the good stuff:
You know those annoying struct initialization calls in your old VB6 code? Poof! Gone! VBUC 10.1 now auto-magically initializes your structs with default values. Imagine structs just springing to life ready to use - that's what we're talking about. Code gets cleaner, you get happier.
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
private struct RECT { public int Left; public int Top; public int Right; public int Bottom; public static RECT CreateInstance() { RECT result = new RECT(); result.Left = 0; result.Top = 0; result.Right = 0; result.Bottom = 0; return result; } }
private struct RECT { public int Left; public int Top; public int Right; public int Bottom; }
Tired of typing those same old using statements over and over? VBUC feels your pain. Now there's this cool "GlobalUsings" file where you stash all your common using declarations once, and they magically work everywhere. It's like spring cleaning for your code!
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { // ... } }
namespace WindowsApplication1; public partial class Form1 : Form { // ... }
global using System; global using System.Collections.Generic; global using System.ComponentModel; global using System.Data; global using System.Drawing; global using System.Linq; global using System.Text; global using System.Threading.Tasks; global using System.Windows.Forms;
3. Expression Bodied Members: Short and Sweet
If you've got a method, event or property that's just doing one little thing, why waste space? Now you can use expression bodied members to make 'em snappy and readable. It's the little things in life, amirite? (Note: If you're an old school coder, there's an option to turn this off.)
Private Function GetName() As String GetName = "John Doe" End Function
private string GetName() { return "John Doe"; }
private string GetName() => "John Doe";
Private Sub Button1_Click() MsgBox "Hello, World!" End Sub
private void Button1_Click(object sender, EventArgs e) { MessageBox.Show("Hello, World!"); }
private void Button1_Click(object sender, private void Button1_Click(object sender, EventArgs e) => MessageBox.Show("Hello, World!");
Public Property Let Name(Value As String) m_Name = Value End Property Public Property Get Name() As String Name = m_Name End Property
public string Name { get { return m_Name; } set { m_Name = value; } }
public string Name { get => m_Name; set => m_Name = value; }
Got DataEnvironment files in your VB6 project? No problem! VBUC 10.1 now handles those migrations like a pro. Upgrading shouldn't break your data connections.
// DataEnvironment migration not supported
public class DataEnvironment1 : DataEnvironment { private Connection1 connection1; private Command1 command1; public DataEnvironment1() { connection1 = new Connection1(this); command1 = new Command1(this); } public Connection1 Connection1 => connection1; public Command1 Command1 => command1; private sealed class Connection1 : ConnectionBase { public Connection1(DataEnvironment parent) : base(parent) { // ... } } private sealed class Command1 : CommandBase { public Command1(DataEnvironment parent) : base(parent) { // ... } } }
Working with Microsoft Message Queue? VBUC's got you covered. You can choose to generate MSMQ as Interop, or if you're feeling adventurous, go with native .NET classes. (Just a heads-up - native .NET stuff won't work if you're targeting .NET 6 or higher).
Dim objQueue As MSMQQueueInfo Set objQueue = New MSMQQueueInfo objQueue.FormatName = ".\Private$\MyQueue" objQueue.Create
MSMQQueueInfo objQueue = new MSMQQueueInfo(); objQueue.FormatName = @".\Private$\MyQueue"; objQueue.Create();
MessageQueue objQueue = MessageQueue.Create(@".\Private$\MyQueue");
Love those VBScript regular expressions? Well, now you can have them in proper .NET flavor with the System.Text.RegularExpressions class, or stick with the Interop wrapper if you like. Regex power the way you want it.
Dim regEx As New RegExp Dim strPattern As String Dim strInput As String Dim strReplace As String Dim strOutput As String strPattern = "\b(Hello)\b" strInput = "Hello, World!" strReplace = "Hi" With regEx .Global = True .MultiLine = True .IgnoreCase = False .Pattern = strPattern End With strOutput = regEx.Replace(strInput, strReplace)
RegExp regEx = new RegExp(); string strPattern = @"\b(Hello)\b"; string strInput = "Hello, World!"; string strReplace = "Hi"; string strOutput; regEx.Global = true; regEx.MultiLine = true; regEx.IgnoreCase = false; regEx.Pattern = strPattern; strOutput = regEx.Replace(strInput, strReplace);
string strPattern = @"\b(Hello)\b"; string strInput = "Hello, World!"; string strReplace = "Hi"; string strOutput; Regex regex = new Regex(strPattern, RegexOptions.None); strOutput = regex.Replace(strInput, strReplace);
VBUC 10.1 - VB6 to C# Migration includes several other features that improve the migration experience:
Support for Visual Studio 2010, 2012, 2013 and 2015 has been deprecated in this release.
To take advantage of the new C# features, expanded library support and other improvements, we recommend upgrading to VBUC 10.1. The VB6 to C# migration upgrade process is straightforward and our team is ready to assist you with any questions or concerns.