Differences Between the CognosScript Language and Microsoft Visual Basic for Applications

Microsoft offers a modified version of Visual Basic in some of its products, called Visual Basic for Applications. In addition to the functions and statements unique to the CognosScript Language, there are differences you will notice between the CognosScript Language and Microsoft Visual Basic for Applications.

In Microsoft Visual Basic for Applications

  • a Global Const is treated as a Const. An equivalent would be Public Const.
  • there are differences in the behavior of the Declare statement:
    • Forward declarations to functions are not available.
    • The BasicLib attribute is not recognized and should be converted to Lib.
    • The Ordinal attribute will not be treated as an ordinal number of a procedure of an external dll unless it is prefixed by "#".
  • prompted user input in the form of the Input or Line Input statement are not available.
  • the Print statement when used without a file number should be changed to the equivalent Debug.Print statement.
  • can not access clipboard objects are not accessible.
  • the Erl function is not recognized.

Dialog Box Capabilities and Microsoft Visual Basic for Applications

Microsoft Visual Basic for Applications does not have a syntax to create or run dialog boxes. In response to this, the CognosScript Language has a set of functions and statements to enable the use of dialog boxes (they are similar to those in Word).

Microsoft Visual Basic for Applications does provide dialog box handling statements and functions. However, the CognosScript dialog functions and statements will not work directly in Visual Basic for Applications. You must port the dialog scripts to custom user forms.

Differences Between the CognosScript Language and Word Basic

Word Basic is a version of Visual Basic that was included in earlier versions Microsoft Word. Word Basic supports dialog boxes, but it does not support objects. The topics below describe some of the differences you will notice between the CognosScript Language and Word Basic.

Dialog Box Capabilities

The dialog box capabilities in the CognosScript Language and Word are very similar. Word does offer some statements and functions that the CognosScript Language does not, such as DlgFilePreview.

As well, the CognosScript Language offers some features that Word does not, such as:

  • Button
  • Button Group
  • Caption
  • DropComboBox
  • StaticComboBox

In response to the need for certain types of dialog box support, the CognosScript Language offered some dialog box options before Word Basic did. Later, Word Basic came out with their own syntax for these options. As a result, there are differences in the way the two languages handle dialog boxes.

Button vs. PushButton

Button is the original CognosScript Language syntax; PushButton is the Word Basic syntax. The two are interchangeable, and the CognosScript Editor supports both. PushButton is preferred.

Dialog Box Units

The measurement units used in the two dialog box syntaxes are different. The CognosScript Editor supports both, and you can choose to use either.

Since many of our clients have built scripts based on the original CognosScript units, those are the ones used in the Examples. As a result, if you use Word units, some of the dialog boxes created in the Examples may look odd.

User Input Mechanisms

There are slight differences in some of the mechanisms for user input.

The following table shows these differences

The CognosScript Language Word Basic

StaticComboBox or ComboBox (in the CognosScript Language, these are interchangeable)

ComboBox (Word Basic supports only this syntax)

DropComboBox

N/A