Difference between revisions of "Visual Basic for Applications"
Jump to navigation
Jump to search
(Created page with "== General ==") |
(Keyword limitations) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== General == | == General == | ||
+ | |||
+ | == Conventions == | ||
+ | * [[VBA Code Guide|Code Guide]] | ||
+ | * [[VBA FAQ|FAQ]] | ||
+ | |||
+ | == Concepts == | ||
+ | * [[VBA Module|Modules]] | ||
+ | * [[VBA Class|Classes]] | ||
+ | * [[VBA Event|Events]] | ||
+ | * [[VBA Interface|Interfaces]] | ||
+ | * [[VBA Convention over Configuration|Convention over Configuration]] | ||
+ | |||
+ | == Code == | ||
+ | * [[Developer Tool Bar]] | ||
+ | * [[Array functions]] | ||
+ | * [[VBA HTML|HTML]] | ||
+ | * [[VBA XML|XML]] | ||
+ | * [[Data Abstraction Layer]] | ||
+ | * [[Status]] | ||
+ | |||
+ | == Problems and solutions == | ||
+ | === Double code execution === | ||
+ | ;Problem | ||
+ | :The function provided with the OnAction property is executed twice. | ||
+ | ;Solution | ||
+ | :Put the function name in single quotes: | ||
+ | <syntaxhighlight lang="vb"> | ||
+ | .OnAction="'functionname'" | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Corrupt Microsoft Access database === | ||
+ | ;Problem | ||
+ | :Microsoft Access gives strange errors, when trying to compile the project. | ||
+ | ;Solution | ||
+ | :[[Decompile Microsoft Access Database|Decompile your database]] | ||
+ | |||
+ | == Tricks == | ||
+ | === Keywords === | ||
+ | If you need to use keywords in an enumeration, for example, you can escape the keyword check with square brackets: | ||
+ | <syntaxhighlight lang="vb"> | ||
+ | Public Enum Keyword | ||
+ | [Boolean] = 1 | ||
+ | [Integer] = 2 | ||
+ | [String] = 3 | ||
+ | End Enum | ||
+ | </syntaxhighlight> | ||
+ | As whenever you push the limits of a language, there is always a downside, which needs to be considered carefully: | ||
+ | user defined keywords usually have precedence over system keywords. So if you specify, for example, an enumeration | ||
+ | with <code>Array</code> as keyword, you will need to either specify any occurrence of the <code>Array</code> function | ||
+ | with the corresponding parental object or you will receive errors like "data field expected". |
Latest revision as of 15:01, 18 June 2016
General
Conventions
Concepts
Code
Problems and solutions
Double code execution
- Problem
- The function provided with the OnAction property is executed twice.
- Solution
- Put the function name in single quotes:
.OnAction="'functionname'"
Corrupt Microsoft Access database
- Problem
- Microsoft Access gives strange errors, when trying to compile the project.
- Solution
- Decompile your database
Tricks
Keywords
If you need to use keywords in an enumeration, for example, you can escape the keyword check with square brackets:
Public Enum Keyword
[Boolean] = 1
[Integer] = 2
[String] = 3
End Enum
As whenever you push the limits of a language, there is always a downside, which needs to be considered carefully:
user defined keywords usually have precedence over system keywords. So if you specify, for example, an enumeration
with Array
as keyword, you will need to either specify any occurrence of the Array
function
with the corresponding parental object or you will receive errors like "data field expected".