VBA vs. VB.Net — What’s the Difference?
VBA is the programming language behind Microsoft Office. It is derived from a programming language called Basic. VB (Visual Basic) is also derived from Basic. For nearly all programming purposes, they are the same language.
VB can either refer to straight Visual Basic (the last version was VB 6.0, and was very similar in syntax to VBA) or VB.Net. The latest version of VB.Net is 2019. VB 6.0 is for all intents and purposes redundant, as VB.Net has replaced it entirely. However, you may still find a few old programs that run off a VB6.0 exe file!
How are they similar?
VBA is written in an editor called the VBE – the Visual Basic Editor. To access the VBE, you can press Alt F11 on your keyboard from within Word, Excel, PowerPoint or Outlook, for example.
The screen is made up of a module window, a project explorer, a properties window and an immediate window. There are other windows available, which you can access by clicking on the Window menu.
Visual Basic is written within Visual Studio. If you open visual Studio and create a new VB.Net Project, you will see that the screen is made up of the module window, the solution explorer, and the properties window. Once again, other windows are available from the Window menu.
As you can see from the two pictures above, the two environments share a lot of features – they both have an explorer window to show you what objects (forms and modules) are stored in the project you are working in. They both have a properties window to show you the properties of the objects you are working with. They also both have a module window to show you the code that you are creating.
How are they different?
VBA works within a host environment such as Microsoft Office or SAGE Accpac. It cannot be compiled to an individual program (like an EXE or DLL file), but is used to customize objects in their host environment. You can create a form in VBA, for example, that you can use to populate your Word Document or Excel Worksheet. You do not need to install any additional software onto your PC to access VBA – it is built into the host environment.
VB.Net is written within Visual Studio and can compile to an EXE or DLL File. This means that the programs can run independently and can be installed and operated from the Start menu in Windows.
In order to use VB.Net, you will need to have a copy of Visual Studio installed on your PC. You can use Visual Studio Community which is free and does not require a license from Microsoft. If you wish to use Visual Studio Professional, you will need a license for it. The professional version of the software has more features available, but the way they work is essentially identical.
Which one should I use?
That depends on what you are trying to achieve! As you can see from the explanations above, VBA is used very specifically within Word, Excel, PowerPoint etc, while VB.Net is used to create independent EXE and DLL programs. If you are customizing Excel with forms and code, you would usually use VBA, but if you are writing a program that you wish to work as a standalone executable, you would need to use VB.Net.
One thought on “VBA vs. VB.Net — What’s the Difference?”