Transforming Legacy Visual Basic Desktop Applications into Cutting-Edge .NET Web Solutions Effortlessly

Md Shofiul Islam
Brain Station 23 PLC.
7 min readJul 2, 2024

This article is about converting the legacy Visual Basic project to web-based application, particularly those developed before 2008, and now need to incorporate contemporary business requirements. These older systems are hard to expand and upgrade, also potentially raise security concerns due to lake of security patches and maintenance. This article shows how a legacy system can be migrated to a modern web-based system, such as.NET MVC application by leveraging the generative AI in an efficient way that minimizes both technical debt and development time.

Benefits of Choosing Web Applications Over Desktop Applications

Adopting web-based applications over desktop applications has numerous benefits for business owners, particularly in areas such as accessibility, maintenance, and affordability. Web application runs in a browser, meaning employees and consumers can access the application from any device, that’s boosting versatility and productivity. Moreover, system upgradation process is more centralized and transmitted immediately to all users without the need for additional installations, that ensures everyone is using the most recent and updated version. Furthermore, web applications demand less user-device storage and computational power, which is more cost savings for both consumers and business owner. This combination of easy access to latest version, quicker upgrades, and cheaper operational expenses makes web applications an excellent option for business owners and consumers.

Additionally, Data management and integration are easier in web-based application than desktop application. The data is stored centrally, which is consistent and accessible in real time. Integration with other web-based services and APIs is also simpler, allowing a system to extent its abilities with extra functions, such as payment gateways, social media platforms, and more, without major additional difficulties.

Action Plans

Dissect the Visual Basic Code:

The process begins with collecting a legacy Visual Basic project from GitHub. After finding the project, we launch the project in Visual Studio to inspect the project. However, the first tasks were to configure the database connections as specified in the Visual Basic project to make sure that all data operations work properly. Once the database connected, we run the project to fully understand its flow and functionalities. This step is critical because it helps us to become comfortable with the existing codebase and identify essential components.

Environment Setup for .NET-8 Application:

Setting up the environment for .NET-8 requires several key steps to ensure a smooth transition from Visual Basic to .NET. Initially, we installed the .NET 8 SDK and created a new MVC web application to redesign the existing application. In order to improve the application’s functionality and provide the top-notch user experience, we’ve incorporated the most recent versions of Bootstrap for responsive design, DataTablesJS for complex table interactions, and jQuery for the other frontend logics. And for the database operations we’ve installed the Entity Framework package and its dependencies from the nuget package manager.

Code Conversion:

The code conversion phase is where the transformation really takes shape. We wrote a comprehensive prompt with the step-by-step instructions for ChatGPT to help us converting Visual Basic code into modern .NET components. This includes creating database models, services and their interfaces, and controller code. Beside that we also instructed ChatGPT to transform the legacy UI (Desktop UI) into responsive HTML, CSS, and Bootstrap designs. This automated technique maintains legacy functionality while implementing new web standards, and also assembled a strong and user-friendly web application.

Available Options and Their Limitations

Visual Basic Upgrade Companion (VBUC):

The Visual Basic Upgrade Companion (VBUC) is primarily intended to convert Visual Basic applications to .NET desktop applications, rather than web-based applications. While VBUC can update and migrate an application to a more recent .NET framework, it does not typically convert the desktop applications to web applications directly. To adapt the converted .NET code to a web application, it requires more manual effort, such as rewriting UI components and integrating web technologies.

Migration Partner:

Migration Partner is a tool designed to assist with the migration of Visual Basic applications to.NET. Like VBUC, it also specializes on converting VB code to .NET-compatible code, which is used to create desktop applications. Migration Partner offers tools and support for an easier transition, but it does not automatically convert desktop programs to web applications. And developers would need to do further customization, such as upgrading the UI and integrating required web technologies and frameworks.

Code Converter (VB — C#) Extension:

Like the VBUC and Migration Partner, the Code Converter is a tool specifically designed to convert Visual Basic code to C#, focusing on desktop applications. it does not support desktop applications to web applications transition. This makes it unsuitable for situations where a shift from desktop applications to modern web-based solutions is needed.

In summary, VBUC, Migration Partner, and Code Converter (VB — C#) allow convert Visual Basic desktop applications to .NET desktop applications, but not straight to.NET web applications.

Our Strategies to the Transition

During the dissection the Visual Basic Code we uncovered that the application has two partial classes in each component. One is [name].cs and other is [name].Designer.cs. The [name].cs file contains the core backend logic and database operations. And [name].Designer.cs file contains the blueprint of the desktop application’s interface.

Step-1: Crafting the Prompt

ChatGPT version: ChatGPT 4

In the prompt, the AI assistance has been assigned for transforming legacy Visual Basic code to modern C# using.NET 8. The first and initial instruction was to handle and analyze *.vb and *.Designer.vb files. The *.vb files, which contain the fundamental logic and database operations, it also be studied to extract database models, interfaces, associated service implementations, and controllers. Furthermore, the SQL queries integrated in these files are examined to make sure that the generated database models are accurate and efficient. The *.Designer.vb files, which contain the user interface, are converted to web-compatible formats using HTML, Bootstrap, CSS, and jQuery. Tables are handled with special attention since they are turned into dynamic DataTables.

Prompt:

Response Format:

Step 2: Feeding the files

In this step, I fed ChatGPT with two different types of files: *.vb and *.Designer.vb . The *.vb files are required for creating the backend code, which consists of the database model, service interfaces, service implementations, and controller code. This step is critical for ensuring that the legacy system’s logic is appropriately translated into the new C# framework. Concurrently, the .Designer.vb files are utilized to generate frontend code. This includes creating HTML structures, styling using CSS, integrating Bootstrap for responsive design, and using Datatables to improve interactive data presentation. This dual focus enables ChatGPT to handle both computational logic and user interface, making it a comprehensive solution for updating legacy systems.

Page-1
Page-2
Page-3
Page-4

As you can see it gives me the DB model, service interface with methods’ name, implementation of the interface, controller code and the top-level UI code for the website.

Challenges

This proof-of-concept project shows significant success, notably with backend code conversion, however there are small difficulties in UI translation. While the backend was expertly converted to .NET, the initial UI codes only give the top-level output, requiring more information for full functionality. This constraint was successfully solved through iterative detailing. The use of visual references(screenshot) considerably improved the AI’s capacity to generate accurate and visually appealing web interfaces. This problem shows, in some cases we still need human to instruct the AI working properly.

Time spent using ChatGPT:

The project we choose has mid-level backend and UI complexity and it has 6 sections including the login page. We successfully develop the whole project within 2-man days, which demonstrates the efficiency of AI and significance of proper prompt designing.

Result

Visual Basic Desktop Application:

Visual Basic Desktop Application

.NET MVC web application:

Converted web-based .NET Application

Conclusions

In the article, we successful showed, how easy the transition from legacy visual basic desktop application to .NET web application. The generative AI not only just make the process easy, but also it notably reduced the development time. It also proves that with the right instructions and information, we can leverage the power of generative AI to simplify tedious and time-consuming tasks, such as making the complex UIs those are interdependent on each other.

--

--