Extrapolating VB to VBA

Banana

split with a cherry atop.
Local time
Today, 11:47
Joined
Sep 1, 2005
Messages
6,318
I want to get a better idea of how much I can expect to extrapolate what I will be learning in my VB class to VBA for Access. I already came across some new terms that I've never seen in VBA, and some terms VBA would not accept at all.

The teacher says that what I learn in VB will apply to VBA but not the other way. But I'm skeptical of this... I'm using Visual Studio 2005 for VB, and I have Access 2003.

Any insights will be appreciated.
 
VBA is more like VB 6.0 than VB.NET (I think VB.NET which is what you get with VS 2005). Generally speaking there are more similarities than differences with the syntax at the statement level. However, at the module level, the differences are significant.

Examples of important differences:
1. VBA does not support OO features like VB.NET. Hence, features such as inheritance and polymorphism are not available in VBA. You can create classes in VBA, but they are not quite the same as a class in VB.NET.
2. VBA uses different libraries for everything. For example, VBA controls are different than VB.NET controlsm etc.
3. VB.NET must be run through the .NET Framework, which is basically a virtual machine that runs p-code like compiled code from .NET. VBA does not require the .NET Framework to run. Instead, it VBA runs within the application in which you are writing the code (e.g., Access or Word).
4. VBA error handling is quite different. There is no structured error handling. It uses the "ON ERROR..." statements.
5. VBA features are much more limited than VB.NET.

There are many other differences, but hopefully you get the idea. My advice - learn VBA by getting some VBA or VB 6.0 books from the bookstore.
 
Is it possible for me to get VBA to use .NET or VB library?
 
Yes to both. However the paths are quite different. To call VB.NET from VBA you need to create a wrapper around the VB.NET code. There is a utility in Visual Studio that does this. I have not used it before., but it makes a regular dll file that calls the .NET dll file. You will need the .NET framework installed to do this. Then just treat the wrapper dll file as a regular dll file (see next).

Regular dll's can be added using the "Tools->References" menu item in the VBA code editor.
 
Is it also possible to get Access to recognize Visual Studio as a IDE instead?
 

Users who are viewing this thread

Back
Top Bottom