Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 to .net

Status
Not open for further replies.

N1GHTEYES

Technical User
Jun 18, 2004
771
GB
The IT Gods here at work have decreed (without reference to the engineers - as usual) that, in the desktop upgrade we will be getting in about a year's time, VB6 will be scrapped and replaced by .net.

I've got huge piles of VB6 code (snippets, libs, apps - all sorts of stuff) totaling, oh, I don't know, several hundreds of thousands of lines of code. I have not used .net, but I have heard that unlike 4->5 and 5->6, I can't just run my VB6 code in .net and expect it to work.

So, firstly, can anybody confirm / deny this statement?
Secondly, can anyone suggest a ballpark figure for the effort required (say, per thousand lines of code) to convert from VB6 to .net?

Once we lowly engineers have been told something will happen, it is usually set in stone, so the chance of my persuading them not to do this is slim, but does anyone have any killer reasons NOT to convert? Is there, for example, anything that VB6 does which cannot be done in .net (or which is slower, or more difficult etc).

Does anyone want to champion .net and tell me why it IS a good idea to change?

Is coding in .net RADICALLY different? How much of a learning curve is there for a (moderately) competent VB6 programmer to learn to use .net?

Basically, any light you chaps (and chapesses) can throw on this, either to equip me to argue against it, or to prepare for it, would be appreciated.

Thanks in advance,

Tony
 

First - I am sorry they made you to move to Micro$oft .NET stuff.

You can – according to Micro$oft – transfer VB 6 code into .NET, but it works only for a very (very) small applications with a few lines of (very simple) code. Just open VB 6 code in .NET and it will run automatic transfer – but it will not work in 99% of situations. Any (more than simple) code and you have to re-write it.

You can, thou, have VB 6 and .NET installed on the same computer and they both will work OK.

That’s my $0.02

---- Andy
 
If I manage to persuade them to let me have both 6 & .net, it will be a major achievement. The PC setup here is locked down tighter than a duck's arse in general, and getting an exception takes persuasion skills just slightly greater than those needed to to convince Everest to take up residence in your garden.

Do you know if ALL VB6 code is translatable (even manually)?

Tony
 
I have found performance issues in VB.NET and C# for manufacturing instrumentation applications that have caused us to delay moving from VB6 and C++. I found that our instrument sampling rates dropped from 250+ samples/sec in a VB6/C++ environment when the same app was deployed in C#.
 
Tony,

I think it is a must to have VB 6 when you want to move to .NET

You may want to ask them what they would rather have:
1. Just .NET on your machine and wait for anything about 2 years, new stuff or modifications to old code, or
2. Allow you to have VB 6 so you can use logic, ways, etc. and a lot of code that you can (somehow) transfer into .NET - and they can have you back in, let's say - in 6 months working in full throtle.

Their choice.

--- Andy
 
I started a few months ago to start on converting some of my key VB6 apps to .NET (I have both on my PC). What a nightmare! I gave it up in the end and have decided that I will need to re-write evrything. However, I absolutely hate .NET - it seems to have made everything so difficult compared with nice, comfortable classic VB6 (with which I have always managed to do EVERY complicated task required of me!). Why can't the world just stand still for while? I only started on this whole episode because I have heard rumours that VB6 will not necessarily be supported on Vista onwards... I imagine (or hope!) that is just a scare to make us all upgrade to .NET !

Good luck!
 
avanderlaan:
I tend not to do any real-time stuff or external interfacing as you mentioned, so that, in itself, is not an issue. But are you suggesting that it is slower in general? That would be an issue. BTW, you said the sample rate dropped from 250+, but not what it dropped to.

Andy:
Good point - I ought to at least have a crossover period when I have both, so I can switch between the two when trying to get the 6 code working on .net. As I say, persuading the high-and-mighty IT Gods is not an easy task, but that is an argument worth making. Thanks.
6 months at full throttle
- you're scaring me. Is the conversion really that bad?
 
sacsac - thanks for that. Can you give me any hard and fast examples of the kind of trouble you had:

a - doing the conversion?
b - something hard to code in .net which is easy in VB6?

- Tony
 
Just to show a little difference:
If you want to change a cursor to hour glass, and then change it back to the regular pointer, in VB 6 you would:

Code:
Me.MousePointer = vbHourglass
'Some code here
Me.MousePointer = vbDefault

In VB.NET

Code:
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
'Some code here
Me.Cursor = System.Windows.Forms.Cursors.Default

and after a few months you will discover that you may as well do
Code:
Me.Cursor = Cursors.WaitCursor
'Some code
Me.Cursor = Cursors.Default

Plus, all recordsets, or whatever they call them in .NET, are disconnected.
(I think they are getting away from this idea and comming back to connected world, but I am not sure)

I had some classes to learn .NET, and teachers could not tell me any other way to deal with DB other than bound controls, which I can not stand. Give me old ADODB and code and I can do anything. Bound controls is just as bounding my hands.

And I could not get any teacher to explain to me all files that .NET creates and what they are for. You have several subdirectories, and files like .vb, .resx, .log, .sln, .vbproj, .vbproj.user

--- Andy
 
Don't be afraid of change. .NET is not that hard, it's just new to people and they don't know how to use it, that's why most people say it's hard. Yes there is a slight learning curve in understanding the new syntax but an IF-then-else block is an if-then-else block no matter what language you use. You just have to get to know the syntax.

In developing you know what you want to do example create a message box. In vb6 you know how to do that because you have been doing it for years probably, but when you first started using VB you did not know how to create a message box. That said now you know what you want to do, it's just a matter of using the help and finding out how the new way to do it is .NET once you find out you will know forever like VB6. With .net they are going towards being a more object Oriented language.
 
kss444:

At last - someone who thinks .net is a good idea. I'm not scared of the change - I'm just curious about how many hours it will cost me and whether it is worth it. Since you seem to like .net, can you suggest how it is better?

For example: Is it faster? Do I get better innate control over graphics (without having to resort to the API)? Does it have better inbuilt maths libraries? Does it automatically implement version control? Does it allow child-in-child forms (again, without API)? Does it give me bit-level access? Does it have innately better routines for array manipulation? etc...

What pay-off do I get for all the time I'm going to have to spend converting my old code and learning the new?

Tony
 
Bound controls is just as bounding my hands.

I LOVE using flex grids in VB6 but can't find that control in .NET. All of the controls seem to be bound. I did once use the "Convert" wizard to convert a VB6 app to .NET but got some errors about "unlicensed controls" that had to do with the ListView control.



AMACycle

American Motorcyclist Association
 
Nighteyes,

I saw maximum sample rates drop to 50-60 channels per second.
 
I have recently switched from Visual Objects (a CA product) to VB.net.

Visual Studio 2005 is really nice to work with. However it can be intimidating, since there is an object and method for everything. I purchased a $750 .net training course on CD, and a couple of books. Then too you need the learn the new ADO.net - which is not like ADO at all - except they kept the name.

After about a month, I had a small 'shell' of an app. I would say after about 3 months you will be comfortable.

IMO you are going to have to rewrite the VB6 apps, I don't see a way of 'converting' them.

If you can, learn it with a friend.
 
OK - I'm seeing lots of stuff that tells me this is not going to be an easy change. Can anyone suggest any reason why it is worth the effort?

Several people have suggested ways in which it is different, but can anyone tell me why it is better? Is this purely and simply a case of Microsoft finding a way to make more money? Or are there any actual, genuine advantages to be gained from the change?

Tony
 
Off the top of my head, I seem to remember that .NET was supposed to solve "dll hell." It has, though, introduced it's own, new hell of .NET version incompatibility.

And all the .NET languages are compatible at the byte-code level.

Need any of this?
 
I understand - I think - what you mean by "DLL hell", but I'm not sure how .net solves it. And could you expand on:
"all the .NET languages are compatible at the byte-code level"?
Tony
 
I am currently moving from VB6 to .NET voluntarily. The reasons are:

1. I want to code new applications. As .NET is taking over, VB programming is rapidly becoming a tool only used to support legacy applications.
2. .NET is a great programming tool. What I really love is the full support of object oriented coding, especially inheritance (which is something I often wished for in VB).

To answer one of your questions, .NET can do everything VB6 can, plus a lot more.

Regarding the different languages, what harebrain was referring to was that all the .NET languages (VB.NET, C#, managed C++, etc.) are precompiled to a common intermediate language. What this means is that you can choose which language you feel most comfortable with, and use it. And somebody else on your programming team could create assemblies using one of the other languages, but you would be able to use his compiled code just as easily.

Regarding the learning curve, it is indeed not trivial. It's not really the syntax, but the overall concepts. One of the mantras I keep repeating to myself that helps me is "Everything is an object". You really must have a firm grasp of object oriented coding to make your way in .NET. So my first advice is that you learn the overall concepts before looking at the VB.NET language itself.

ADO.NET is quite different from ADO - but quite for the better. For example, using DataSets and multiple DataTables, and setting up references between the DataTables, you can create "mini-databases" in memory which even enforce relationships. You can get subsets of data rows with filtering methods. You can easily find out which rows are dirty, or cancel changes you made to the row. Another thing I like about ADO.NET is that unlike ADO there is the acknowledgement that not all database systems are equal. So there is one level of objects that is generic for all databases (for example, DataTables), but there are also objects that are tailor made for a specific database (example: SQL Server).

Your question regarding is it worth it to convert? That decision should really be made on an application by application basis. I'm sorry that you are subject to a dictate that doesn't seem to be based on any sort of requirements analysis. Old programs that are running well and will need little or no modification in the future, should probably be just left alone. You may find however that for applications that evolve rapidly, that the object oriented nature of .NET will be quite a blessing.

If you have been developing your VB apps with an n-tier architecture, you could take advantage of .NET's Interop services to make the transition more gradual. Interop basically allows your .NET code to reference COM objects, and vice versa. So for example, you could create a new UI in .NET (windows forms or ASP.NET web forms), but continue to use your existing business objects.

So I would encourage you to look at this as an opportunity. .NET is not just a new money maker for Microsoft - there is a reason why so many programmers are moving to it.
 
Andrzejek,

Any teacher who doesn't know the difference between a .vb code file, a .sln solution file, and a .vbproj project file has no business teaching others. I would regard everything that person has "taught" as suspect. Get a good book instead and teach yourself (this has always been my preferred method of learning).
 
Dear N1GHTEYES,

I am not surpised that your company decided to move to .NET. I would be if they didn't because for at least me, vb6 is ..dead meat. You will find some difficulties in moving from event driven language vb6 to the OOP .NET. This should not scare you.
In .NET there is an upgrade tool for the vb6 projects... that you should not use. One basic rule is that: keep vb6 projects in vb6 and write the new ones in vb.Net. It is a waste of time trying to upgrade vb6->.NET. It will be alot better if you start existing projects from scratch.

When you will have a little experience with .NET then you will see the many advantages. Now I personally do not change .NET for nothing.

___________________
PS: I started will very very little vb5, then vb6 and last .NET. I was really excited to see .NET grow up ( 1.0 -> 1.1 -> 2.0! )

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top