PDA

View Full Version : Transferring to VB.net



Djblois
05-05-2007, 06:54 AM
I just bought a few books on VB.net and I am thinking about porting my code over to it but I have a few questions.

1) Can I write an Excel add-in using VB.net?

2) How much of the code in VBA is usuable in VB.net without change? I know I will have to change code but will I have to change 50%, 75%, or 100%?

3) does anyone know a website like this one that helps with VB.net? I am looking and can't find one.

The reason for my decision is some more advanced things that I want to do can not be done on VBA.

Bob Phillips
05-05-2007, 09:34 AM
I just bought a few books on VB.net and I am thinking about porting my code over to it but I have a few questions.

1) Can I write an Excel add-in using VB.net? Yes for 2003 and 2007

2) How much of the code in VBA is usuable in VB.net without change? I know I will have to change code but will I have to change 50%, 75%, or 100%?

It can, but you will still have ton of work to do because VB.Net is within the .Net framework, and VBA knows nothing of that. Plus ... because Vb.Net is not being run in a hosted container application, you will have to access Excel via automation.

3) does anyone know a website like this one that helps with VB.net? I am looking and can't find one.

Not really.
The reason for my decision is some more advanced things that I want to do can not be done on VBA. Such as? To be perfectly frank, I think you need to master VBA more before you trying moving to .Net.

Norie
05-05-2007, 10:46 AM
You'll probably need to totally rewrite the code.

It can't just be transferred to VB.Net.

The main reason for this is because you'll have to use automation as xld has pointed out.

Djblois
05-05-2007, 10:51 AM
thank you for the answers. I didn't plan on moving to vb.net right now. I am trying to learn about both and the differences first. over time I will try to port the code over

Bob Phillips
05-05-2007, 11:03 AM
As I said, what do you think that VB.Net can do that VBA cannot?

tstom
05-06-2007, 06:17 PM
1) Can I write an Excel add-in using VB.net?
Yes. From 97 on up though you are better off using VB6 for 97.
Office 2000 and up for automation servers via COM interop.

2) How much of the code in VBA is usuable in VB.net without change? I know I will have to change code but will I have to change 50%, 75%, or 100%?
It really depends on what your are coding for now. Most of the code that refers to the Office, Excel object model will readily port with some minor changes on your part. A good practice for now is to avoid certain practices. Google the "Code Advisor for Visual Basic 6" and check out what you should avoid in your current projects if you are planning on porting them to net. Most of my Office projects, though fairly small for the most part, required very little adjustment.

3) does anyone know a website like this one that helps with VB.net? I am looking and can't find one.
There are more than a handful of decent VB/Net forums out there.

The reason for my decision is some more advanced things that I want to do can not be done on VBA.
Well... IMO, the net framework is really a great approach to accomplishing much of what you are already doing using VB 6 / VBA. It's not so much "what" as much as how much more easily accessible many functions are in net. The framework is a wrapper for the operating system's API. It is much easier (and safer) to use the classes of the framework than it is to use dll functions. There are many other benefits to ponder as well.

I did not really answer anything that the others posting have already, but they did seem a bit discouraging. If you like programming, you may love the framework. VB is secondary and is only one of a handful of languages that produce the same managed code. The controls offered in VB.Net are much better and more plentious. The properties and events offered are many, many more than in pre net VB. The newer versions of the framework off VB programmers things that they have not had in the past or at least not had easy access to. Operator overloading, generics, flexible delegates, interfaces, inheritance, method overloading, unsigned types, strong typed datasets, GDI+, and many, many more.

http://msdn.microsoft.com/vstudio/express/vb/
Download the free, very functional VB.Net express edition from the above link. Because of the nature of the net framework, there is very little you cannot do in this free version that the very expensive editions offer. You can actually code in notepad and use the same compilers that come with the expensive VS editions without buying anything at all. There are some other free dev. env. out there as well but they don't compare with the above mentioned. Your COM addins will be fully functional but there is a performance hit when writing COM apps in the net framework. The interop is really good but it involves a lot of marshalling. If you really want to develop some great stuff for Office, you will need VS Tools for Office. This allows you the full functionality of the VB dev env within Excel including most of the controls for WinForms that can be placed right on the worksheet. Another thing to think about is the eventuality of multi platform support. If you code for a living, I think the framework is the way to go. That or Java. My bet is on net.