VB compatibility mode makes MaxBasic accept more Visual Basic (VBA) syntax, so code written for VBA needs fewer changes. The mode applies to scripts, custom forms and designed reports. It is the default for new systems and is recommended.
Note: We recommend that VB compatibility mode is on if you use Ace to write or change MaxBasic. See Ace.
Turning on VB compatibility mode
The MaxBasic VB compatibility setting on System Settings - General tab turns the mode on for every script. It is selected for new systems and clear for systems converted from Accredo version 8.
A script turns the mode on for itself with the Option VBCompatibility statement. A script cannot turn the mode off.
Changes in VB compatibility mode
Syntax |
Mode off |
Mode on |
|---|---|---|
Dim x, y, z As Integer |
Only z has the type. x and y are dynamic. |
x, y and z all have the type. |
Not available. While gives an error. |
Available. Wend is a reserved word and cannot be used as a name. |
|
InStr("abc", "") |
Returns 0. |
Returns 1. |
Not available. |
Returns the current machine date and time. |
VB syntax in both modes
MaxBasic accepts this VBA syntax with the mode on or off:
Syntax |
Example |
|---|---|
Round brackets for arrays, as well as square brackets |
Dim Totals(10) As Number |
An initial value in a Dim statement |
Dim Speed As Integer = 60 |
VBA numeric type names, which declare a Number: Integer, Long, LongLong, Byte, Single, Double, Currency, Decimal |
Dim Count As Long |
An optional Start argument for InStr |
InStr(4, "abcabc", "b") Returns 5. |
Note: Before you turn the mode on for a converted system, check Dim statements that list several names before one type. A name that was dynamic now takes the type, and assigning a value of a different type to it gives an error. Also check for variables named Wend.