Review: Instant C# and Instant VB Code Conversion Utilities
page 2 of 5
by Steven Smith
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 37595/ 113

Source Code Conversion

This review covers two products, Instant C# and Instant VB.  I will switch between the two, and as you will see they are nearly mirror images of one another.  Figure 1 shows the main user interface for Instant C#.

Figure 1: Instant C# User Interface

The tool is fairly intuitive to use.  As you might guess by looking at Figure 1, it supports converting complete VB projects (1.x or 2.0) to C#.  A simple way to test this feature is to open up one of the ASP.NET Starter Kits in VB (or VB Starter Kits) and convert it to C#.  I tested the product using several different starter kits and found that it did a good job overall, but there were some things it was unable to convert without some developer interaction.  For instance, Resource files required some manual work to get working in C# after converting from VB.  On the whole, however, the projects were converted about 99% of the way and, of the ones I tested, compiled on the first try.  Figure 2 shows some advanced options that are available for the conversion process.

Figure 2: Instant C# Conversion Options

After converting a project, the tool displays the number of lines of code converted, how long it took (14 seconds for the VB Card Game Starter Kit on my machine), and a list of warnings and errors.  Comments are inserted into the converted code showing warnings and TODO items, with a summary report provided to make it easy to find and correct anything that needs to be manually converted (which is to be expected in any significant, real world project).  Figure 3 shows the end result after converting the VB Card Game Starter Kit.

Figure 3: Post-Conversion Summary

 

In addition to full project support, the tool also supports conversions at the snippet level, which is its most useful feature to me, personally.  When writing a demo for an article or presentation, I typically prefer to write it in C# first, and then convert if dictated by the audience.  I am capable of doing the conversion manually, but it is a time-consuming, tedious process.  Instant VB lets me take my C# code samples and immediately convert them into VB code, complete with support for 2.0 constructs like Generics.  As an example, consider this article on Generics in C#.  Its Listing 5 shows an example of a Stack class that uses Generics, which is implemented in C#.  To convert this into VB for use in a VB library, simply cut-and-paste the code into Instant VB's Snippet Converter, with results as shown in Figure 4.

Figure 4: Instant VB Snippet Converter

 

The result is VB code that works immediately, saving me a few minutes' worth of conversion and (quite likely) some errors on my part in the conversion process.  These minutes add up quickly when you add up all of the demos in a presentation, article, or book, not to mention the times when a solution found on the Internet is not in one's language of choice and needs to be converted.

The Folder Converter utility simply accepts a source folder and a target folder, and will convert all C# (or VB) files in the source folder into VB (or C#) and place the results in the target folder.  This is useful if you wish to convert a bunch of files that are not part of a project, or if you wish to convert a large project one folder at a time.  Since non-WAP web sites in Visual Studio 2005 are simply folders, the Folder Converter is the tool of choice to convert ASP.NET web sites.  It will convert all ASP.NET pages, App_Code files, etc. in the process.

The last tab, ASP.NET Snippets, supports converting ASPX pages which include inline VB (or C#) code in them.  This would have been quite useful to me a few years ago when I wrote the ASP.NET Developer Cookbook with other ASPAlliance authors.  All of its examples used inline ASPX pages to avoid the need for readers to have Visual Studio (since the popular Web Matrix tool did not use code-behind files).  Since all examples were offered in both VB and C#, a lot of manual conversion went into the effort.  With Instant VB, a recipe like 0307 in C# could be converted to VB in a couple of seconds, as you can see from Figure 5.

Figure 5: Instant VB ASP.NET Snippet Converter

 

One general note about code conversion - it will be rare in a real world application that any tool will successfully convert a large real world application from one language to another without any developer intervention.  This is because the VB and C# teams are both trying to differentiate their languages and add value to their languages, often in ways that have no equivalent in the other language.  A good example of this is the yield keyword in C#, which does not exist in VB.  In order to write similar code in VB, one must rewrite not just the method where yield is found, but also the callers of that method, resulting in complexities that may be best left to real programmers to convert.  With that said, I have found the Instant C# and Instant VB products to be very robust, easy to use, and effective in my own use of these products.  The authors of these products share some of their insights into the Art of Conversion Between VB.NET and C# on their website.


View Entire Article

User Comments

Title: One way to convert VB6 To C#   
Name: Steven Barden
Date: 2011-04-01 3:41:17 PM
Comment:
I am currently performing the conversion of more VB6 to WPF than I want to admit. I miss not working SharePoint RIGHT NOW, but this stuff is growing on me. The converter is by ArtinSoft. I did not install it, use it, nor have I converted the code using the product. But what another developer has converted for me takes me weeks to debug. Plus, I am working a 15 year old, COMPLEX VB6 Winform App to C# 4.0 / WPF 4.0. It has allot of bloat ware, and I am not please with all, nor is it perfect, but the longer I use it the more appreciation I have for the developers. This app SHOULD HAVE been remolded from the ground up, but it was not possible. So don't left the so-so review hinder your decision, I am almost always happy to have their product. I have a growing respect for their product all of the time. But they have SCRUBBED their site of any WPF so far. Trust me, If you can go VB6 to C# Winform today, do it. You really may not want to learn all that I have (and have not yet), unless you really have to. But if you try go from many complex VBP's that are almost impossible to get to debug easily (for years), to a minimal amount of C# classes and WPF, you will find the .NET conversion rate around 90% for classes (although it's all C# active like VB6) and 0% on the WPF parts. Through in some personalities where one person is a C# hating C++'r and the other knows the product, but not really how to program, and you better stand tough for yourself if others under-do your time estimates (am I getting to detailed?).

Trust me (or don't, your call) VB6 -> C# Winform only... one day someone will make a converter for Winform to WPF (or just rebuild all of the controls, because you don't want to KNOW what happens to highly complex tree views with some XML functionality and the logic is all based in the VB6 Tree Nodes ;).
Title: covert vb6 to c#   
Name: baghaie amir
Date: 2010-07-19 5:41:30 AM
Comment:
how to convert vb6 to c# program
Title: yadav   
Name: jitendra
Date: 2008-04-02 9:33:29 AM
Comment:
i want to know how we can learn about progromming
Title: converter vb 6.0 to c#   
Name: student
Date: 2007-10-15 5:40:36 PM
Comment:
it is the best






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-07-19 4:58:00 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search