Access.2007.VBA.Bibl..

(John Hannent) #1
TABLE 17.1

Syntax Differences between VBA and VBS Code


Category Omitted Feature/Keyword

Array Handling Option Base Declaring arrays with lower bound <> 0
Collection Add, Count, Item, Remove Access to collections using! character
Conditional Compilation #Const #If...Then...#Else
Control Flow DoEvents GoSub...Return, GoTo On Error GoTo On...GoSub, On...GoTo Line
numbers, Line labels
Conversion CVar, CVDate Str, Val
Data Types All intrinsic data types except Variant Type...End Type
Date/Time Date statement, Time statement
DDE LinkExecute, LinkPoke, LinkRequest, LinkSend
Debugging Debug.Print End, Stop
Declaration Declare (for declaring DLLs) Optional ParamArray Static
Error Handling Erl Error Resume, Resume Next
File Input/Output All traditional Basic file I/O
Financial All financial functions
Object Manipulation TypeOf
Objects Clipboard Collection
Operators Like
Options Deftype Option Base Option Compare Option Private Module
Select Case Expressions containing Iskeyword or any comparison operators Expressions
containing a range of values using the Tokeyword.
Strings Fixed-length strings LSet, RSet Mid Statement StrConv
Using Objects Collection access using!

Though this table is useful, it doesn’t cover all the differences between VBA and VBS code, nor
does it identify the ones that are most likely to cause trouble when converting VBA code to VBS.
When working with both Outlook VBS and WSH scripts I have found a number of differences
between the two dialects of VB that need to be taken into account when writing VBS code (espe-
cially when converting VBA code to VBS). These differences are listed in Table 17.2.

Part III Adding More Functionality to Office

Free download pdf