An implementation of Visual Basic that is built into Microsoft products.
For VBA syntax and function lookup, the most methodical starting points are the Visual Basic language reference and the broader Language reference for Visual Basic for Applications (VBA). Those references organize VBA content by statements, functions, operators, objects, data types, and conceptual topics.
For the specific examples mentioned:
- Dimensioning an array uses the
Dimstatement with parentheses for arrays:
Dim myArray()
The documented syntax is:
Dim varname [(subscripts)] [As type], [varname [(subscripts)] [As type]] ...
Examples from the syntax guidance:
Dim myVar, nextVar, thirdVar
Dim myAnswer As String
Dim x As Integer, y As Integer, z As Integer
Dim myArray()
Key rule: if declaring an array variable, parentheses must be included; subscripts are optional.
- Function and method syntax rules are explained in the Visual Basic syntax topic. It shows how required elements, optional arguments in brackets, placeholders in italics, and keywords in bold are represented.
- Named and positional arguments are also supported. For example,
MsgBoxcan be written by position:
MsgBox "Your answer is correct!",0,"Answer Box"
or by name:
MsgBox Title:="Answer Box", Prompt:="Your answer is correct!"
- Parentheses rules matter when calling functions. If the return value is used, arguments must be enclosed in parentheses. Example:
myVar = MsgBox(Prompt:="I enjoy my job.", _
Title:="Answer Box", Buttons:="4")
If the return value is ignored, the syntax guidance says not to include the parentheses.
For finding available instructions and functions efficiently, use these sections in the VBA reference:
- Functions for built-in VBA functions
- Statements for instructions such as
Dim - Operators for language operators
- Data types for declaration details
- Visual Basic conceptual topics for syntax rules, arrays, scope, variants, and related topics
- User Interface Help in the VBA reference, which includes Visual Basic Editor elements and an error messages section with common causes and solutions
If the goal is a reminder of what exists rather than a tutorial, the best navigation path is:
- Open Language reference for Visual Basic for Applications (VBA).
- Go to Visual Basic language reference.
- Browse Functions, Statements, Operators, and Data types.
- Use Visual Basic conceptual topics for syntax patterns such as arrays, named arguments, optional arguments, and parentheses.
For help inside the editor, the Visual Basic Editor help article also points to help resources available while using the editor.