Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly

Convert C# to VB
by Ken Cox

November 22, 2005

Instant VB converts your C# source code into VB. The bare-bones user interface lets you navigate to the C# project you want to convert, to a directory of projects, or to a text area where you can paste in C# snippets (see Figure 1). The downloadable software comes as a single .NET executable inside a ZIP file. There is no installer, so you need to copy the executable to a directory and create your own shortcuts.

ADVERTISEMENT

The converter works well when fed straightforward C# code with fairly standard formatting. Simply paste a function into the snippet converter, and get back usable, understandable VB.

Notes are embedded comments that provide the original line of code and a brief explanation about what was done, such as "This 'for' loop was translated to a VB 'Do While' loop." To-do tasks (spelled TODO in the code) mark sections that require developer intervention, such as instances where VB.NET has "no equivalent" syntax to C#. Instant VB deals with the difference in case-sensitivity between C# and VB by tacking a "_Renamed" suffix on some variables.

For a real challenge, I pointed Instant VB at the C# source code for a sophisticated 3-D rendering engine. The tool produced a Visual Studio project file and a set of VB classes to parallel the C# version. It reported the conversion of 4,855 lines in two seconds with 83 notes and 38 to-do tasks. At 38 to-do tasks, the translator seriously underreported the number of trouble spots, leaving syntax errors of its own. When I alerted Tangible's support (anonymously) and provided samples, they replied promptly and posted a bug-fix build overnight. The fix handled jagged string arrays and do/while loops containing an end-of-line comment—the cause of many errors. However, check your C# carefully for pointer-oriented code. According to the vendor, it "usually isn't possible" to convert that code to VB.

I'd like to see Instant VB provide an automated feedback mechanism when it can't convert code cleanly. Customers could select a troublesome snippet and post it to a Web service for subsequent analysis and bug fixing. Also, if the conversion tool reports that "assignments within expressions are not supported in VB.NET," it could insert a comment pointing to documentation that helps you understand the issue and perhaps suggests a hack. It also needs a summary report on notes and problems, including filenames and line numbers. As it stands, the best post-conversion reporting tool is Visual Studio's error list.

Instant VB produces a great deal of acceptable, well-formatted code at a good clip and offers a fair 15-day money-back guarantee on top of a trial version. Its challenge is to reduce further the percentage of unconverted content and provide more documentation help when manual intervention is necessary.

Instant VB
Tangible Software Solutions
Web:
www.tangiblesoftwaresolutions.com
Phone: 604-930-9949
Price: $159
Quick Facts: Converts C# solutions, projects, files, and snippets to VB.NET.
Pros: Converts large amounts of well-formatted code quickly; satisfaction guarantee.
Cons: Doesn't create workarounds for unsupported VB functions; leaves behind syntax errors; insufficient reporting.

About the Author
Ken Cox is a freelance developer and programming writer, and a Microsoft MVP for ASP.NET. Reach him at .




Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home