tags:

views:

2838

answers:

5

Hi,

I have a few modules of block of code in vba to run on few access databases. I would like to know how should i proceed if i wanted to convert the coding to c# environment. And is it possible to implement and obtain the same results as i am getting now with access and vba. I am completely new to c# at this point.

+2  A: 

You can find some useful information about this exact topic on msdn here

Brann
+1  A: 

Generally, you should be able go convert the code manually. You won't find any automated code converters that will do it.

That being said, the frameworks which you use to access data are quite different in the C# and VBA worlds (they're even quite different betwween VB.NET and VBA!). So you're going to want to read up on ADO.NET before you get started.

Dave Markle
+2  A: 

Automatic conversion isn't possible at the moment, but doing it manually will also help improve your C# skills. There's a Top 10 article here that takes you through the common differences:

http://msdn.microsoft.com/en-us/library/aa164018%28office.10%29.aspx

You may also find the following links useful:

The MSDN page for developing Office solutions with C#:

http://msdn.microsoft.com/en-us/library/ms228286.aspx

The MSDN Visual C# application development page (for starting out in C# development):

http://msdn.microsoft.com/en-us/library/aezdt881.aspx

Good luck and I hope this helps.

Dave R.
A: 

http://www.developerfusion.com/tools/convert/vb-to-csharp/

Not perfect but it will get you started on the sytax. For the record, this won't compare to what you'll pick up learning it yourself.

Ian Jacobs
That's VB.NET, not VBA. Very different creatures.
Duncan Bayne
+1  A: 

One thing to be aware of is that some object name spaces and library references are included automatically when you are coding in VBA. These need to be explicitly added when working in C#. For example,

Selection.TypeText("foo")

in VBA becomes

using Microsoft.Office.Interop.Word;

Application word = new Application();
word.Selection.TypeText("foo");

in C#. Library references can be added by right-clicking the References folder in the Solution Explorer and choosing "Add Reference".

Eric Ness