Click to See Complete Forum and Search --> : Converting code from one language to another
Nightwalker83
Mar 4th, 2010, 07:18 PM
Hi,
I used to program in Visual Basic 6.0 and until I gave up computer programming in 2007 and have only got back in to it this year. Now, since school stopped teaching vb.net we've be learning c# and that got me thinking is it possible to convert a program written in a language such as vb6.0 into vb.net or c# code without having to rewrite all the code from scratch?
I have been doing some research on the subject and some companies claim to have tools that assist in the conversion of code from one language to another, one such company I found is Great Migrations (http://www.greatmigrations.com/Default.htm).
The above site talks about the methodology they use in order to achieve the results for their client. Well, rewriting the code seems like a hassle when converting from VB6 to .Net but I guess they do more than have the codes for both vb6.0, etc and by trial and error match to corresponding net equivalent?
Also, Is there a lot involved in converting between the .net languages?
This is something I found interesting and I know little about the subject because I might need to upgrade my program code, etc in the future.
Thanks,
Nightwalker
Shaggy Hiker
Mar 4th, 2010, 07:55 PM
There is virtually no problem converting from one .NET to another, but as for moving VB6 to .NET, there you are better off re-writing from scratch. You can crib pieces from the VB6, such as individual functions, interface layout, and some other things, but .NET is an OO language, while VB6 is not. This means that a good design in VB6, while possible in .NET, is not a good design in .NET.
Nightwalker83
Mar 4th, 2010, 08:50 PM
Yeah, someone in another thread talking about c++ to c# code said that there is basically nothing to stop you from converting .net language program to another .net language. How different would the methods used in converting from vb6.0 to.net rather than .net to .net? As stated above that site talks about their own methodology for doing such things. Would it be any different from the other development methodologies?
Newbie 407
Mar 5th, 2010, 01:30 AM
Hi There,
I am a new here and would like your expert opinion.If there a software already coded in Vb.net now needs to be converted/migrated to Asp.Net. Will such a process be time consuming?
thanks in advance
Pradeep1210
Mar 5th, 2010, 02:20 AM
Yeah, someone in another thread talking about c++ to c# code said that there is basically nothing to stop you from converting .net language program to another .net language. How different would the methods used in converting from vb6.0 to.net rather than .net to .net? As stated above that site talks about their own methodology for doing such things. Would it be any different from the other development methodologies?
All .NET languages are compiled to MSIL before execution.
That means that the MSIL for code written in any .net language would be same, and as such is possible to convert from one to another.
It is even possible to write your application partially in one language and partially in another, since both will compile to a common intermediate language at runtime.
But conversion from VB6 to .NET has nothing common in between. VB6 is compiled to binary form while vb.net is compiled to IL. That's why it is not possible to easily convert from one to another.
Pradeep1210
Mar 5th, 2010, 02:23 AM
Hi There,
I am a new here and would like your expert opinion.If there a software already coded in Vb.net now needs to be converted/migrated to Asp.Net. Will such a process be time consuming?
thanks in advance
VB.NET (forms) application and ASP.NET application are technologically different. They render to different UI. A vb.net forms application is designed to be rendered in a window, while asp.net applicaiton renders into a webbrowser. Also vb.net is standalone while asp.net is client-server based. Moreover, the controls are different. e.g. A VB.NET TextBox is not the same as ASP.NET TextBox. They have been coded to be as similar as possible w.r.t. functionality and available members(properties/events/methods). But they derive from different bases.
So it is not possible to convert one to the other.
Nightwalker83
Mar 5th, 2010, 03:44 AM
All .NET languages are compiled to MSIL before execution.
That means that the MSIL for code written in any .net language would be same, and as such is possible to convert from one to another.
It is even possible to write your application partially in one language and partially in another, since both will compile to a common intermediate language at runtime.
But conversion from VB6 to .NET has nothing common in between. VB6 is compiled to binary form while vb.net is compiled to IL. That's why it is not possible to easily convert from one to another.
Ah ok! I thought it would be something like that. What is MSIL and IL? If I ever needed to recode a vb6.0 project in .net is it as simple as picking a language as c# and start replacing the vb6.0 code, etc with the c# code or are there others factors needed to be taken into account?
Pradeep1210
Mar 5th, 2010, 04:55 AM
Ah ok! I thought it would be something like that. What is MSIL and IL? If I ever needed to recode a vb6.0 project in .net is it as simple as picking a language as c# and start replacing the vb6.0 code, etc with the c# code or are there others factors needed to be taken into account?
Microsoft Intermediate Language (also called MSIL or IL in short) is an intermediate language between the machine (binary) language and high level language. In simple words, you may call it a half compiled language. The JIT (Just-in-Time) compiler compiles that MSIL into machine language on the fly when you execute the code, as opposed to VB6 or C++ which are directly compiled to machine language by the compiler.
The benefits of MSIL is that it can determine the most efficient way to execute your code on the move, whereas VB6 programs are precompiled and can't be optimized without compiling from the source code again with different compilation parameters.
There are many more benefits too. Have a look at this:
http://msdn.microsoft.com/en-us/library/c5tkafs1.aspx
Nightwalker83
Mar 5th, 2010, 08:09 AM
Thanks for the insight! Also, while searching in google about how to convert VB6.0 code to C# code I came across a post by Brian Bischof and the link to his book: The .NET Languages: A Quick Translation Guide which, covers the translation between VB6.0, VB.NET and C#. It seems like it might be a good place to start if I were ever in need of a way to convert code between the three languages.
Pradeep1210
Mar 5th, 2010, 08:21 AM
Also Microsoft decided to break compatibility with previous versions of Visual Basic, when VB.NET was introduced. So there are a few things in VB6 that have no equivalent in VB.NET and vice-versa. There are also a few things that are common in VB6 and VB.NET, but work differently in both the languages (e.g. New keyword while declaring a variable etc.). And that's the exact reason why you won't find any converter that can convert the VB6 code to VB.NET with 100% surety.
Nightwalker83
Mar 6th, 2010, 09:10 PM
I found another web page that might be useful for converting the vb6.0 to c# constants.
http://www.netcoole.com/VB6TOCS/vbhtml/vbconsts.htm
gep13
Mar 7th, 2010, 04:13 AM
Hey,
That web page is all well and good, but in order to use it, you would need to include a reference to the Microsoft.VisualBasic assembly in your C# application, which I was never comfortable with doing.
Gary
Nightwalker83
Mar 7th, 2010, 04:30 AM
Hey,
That web page is all well and good, but in order to use it, you would need to include a reference to the Microsoft.VisualBasic assembly in your C# application, which I was never comfortable with doing.
Gary
Which site, the one I posted in post #11?
If you find or know of a better website/solution feel free to post it.
gep13
Mar 7th, 2010, 04:43 AM
Yes, the link that you posted in post #11.
I don't know of any other web site, so I won't be posting any other link, the point that I was trying to make was that I would never include a link to Microsoft.VisualBasic, in a C# application that I was creating. In my opinion, there is no requirement to have to do this.
Gary
Nightwalker83
Mar 7th, 2010, 05:44 AM
Well, since I can't find any other website to do with the constants I will post something else that I found that maybe useful from the above Microsoft site.
http://msdn.microsoft.com/en-us/library/aa260644%28VS.60%29.aspx
Although, that is for VB.Net I would think there wouldn't be a big difference between the .Net languages.
Pradeep1210
Mar 7th, 2010, 09:12 AM
The constants, methods etc. defined in the Microsoft.VisualBasic namespace is for old VB6 programs/programmers, that was created for their convenience or for them to easily migrate code from VB6 to .NET. You would normally not use it in new developments and certainly not in C#. However there is nothing stopping you to do so, just in case you want to.
gep13
Mar 7th, 2010, 12:13 PM
Hey,
This is the point that I was trying to make, but perhaps I didn't explain myself very well. Pradeep said it quite well, in that they are there for convenience, nothing else.
Gary
Nightwalker83
Mar 8th, 2010, 04:07 AM
I'm not actually looking at converting code at the moment just any useful resources in case I need to do it later on.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.