Visual Basic
- Pronunciation
- VIZH-oo-ul BAY-sik
In short
Visual Basic is Microsoft's family of beginner-friendly languages, including classic Visual Basic, VB.NET and VBA, which automates Office apps with macros.
What is Visual Basic?
Visual Basic 1.0 appeared in 1991 and made building Windows applications dramatically easier: you drew buttons and forms on screen and wrote short pieces of BASIC-style code for their events. Version 6, released in 1998, became hugely popular for business applications, and countless internal tools were built with it.
In 2002 Microsoft replaced it with Visual Basic .NET, a fully object-oriented language on the .NET platform with the same capabilities as C#. VB.NET is still supported, but Microsoft stated in 2020 that it would not add new language features, so most new .NET development happens in C#.
The most widely used member of the family today is VBA, Visual Basic for Applications, built into Microsoft Office. Accountants, analysts and office workers use it to write macros that automate Excel workbooks, generate Word documents or process Outlook email, and many businesses depend on such macros every day.
A common misconception is that Visual Basic disappeared. Classic VB6 is long out of support, but VB.NET applications still run, and VBA macros are everywhere in offices. Because macros can run arbitrary code, they are also a classic route for malware, which is why Office blocks macros in files from the internet by default.
Key takeaways
- Visual Basic is Microsoft's family of beginner-friendly languages.
- Visual Basic 1.0 in 1991 made visual Windows app building popular.
- VB.NET, from 2002, is supported but no longer gets new language features.
- VBA automates Excel, Word and Outlook with macros.
- Macros can carry malware, so Office blocks internet macros by default.
Example
' Highlight every order above a limit and count them
Sub HighlightLargeOrders()
Dim cell As Range
Dim count As Long
Const LIMIT As Double = 1000
For Each cell In Worksheets("Orders").Range("C2:C500")
If cell.Value > LIMIT Then
cell.Interior.Color = RGB(255, 235, 156)
count = count + 1
End If
Next cell
MsgBox count & " orders are above " & LIMIT
End SubReaders ask
What is the difference between VB.NET and VBA?
VB.NET is a full .NET language for building applications. VBA is a version of classic Visual Basic built into Office applications for writing macros that automate documents and spreadsheets.
Is Visual Basic still used?
Yes. VBA is widely used for Office automation, and many VB.NET and older VB6 applications are still maintained in businesses, even though new projects usually choose C# or Python.
Should I learn VBA?
If you work heavily with Excel or other Office applications, VBA can save hours of repetitive work. For general programming, Python is more versatile and can also automate Excel.
See also
- C#Programming Languages, p. 4C# is a statically typed, object-oriented language that runs on the .NET runtime with garbage collection and is used for web backends, desktop apps, and games.
- .NETBackend & APIs, p. 1.NET is Microsoft's free, open-source developer platform for building web, desktop, mobile, cloud and game applications, mainly in C#.
- PythonProgramming Languages, p. 26Python is a general-purpose, dynamically typed programming language known for readable syntax and wide use in data science, automation, and web backends.
- MalwareSecurity, p. 20Malware (malicious software) is any program designed to harm a computer or its user by stealing data, spying, damaging files or taking control of the system.
- InterpreterProgramming Fundamentals, p. 30An interpreter is a program that runs source code directly, step by step, instead of first translating the whole program into a separate executable file.
Spotted a mistake or something missing on this page?Suggest an edit