Creating an early-bound object variable

An early-bound object variable must be declared using a Dispatch Interface definition block.  Like a User-Defined Type declaration, these must be located outside of a Sub/Function, and before any reference to the block.  For example:

INTERFACE DISPATCH WordApplication

  MEMBER GET ActiveDocument<&H3>() AS WordDocument

  MEMBER GET Name<&H0>() AS STRING

  MEMBER GET Documents<&H6>() AS WordDocuments

  ...

END INTERFACE

 

FUNCTION PBMAIN

  DIM oWord AS WordApplication

  LET oWord = NEW WordApplication IN "Word.Application"

  ...

END FUNCTION

 

See Also

COM Programming Introduction

The PowerBASIC COM Browser

Creating a late-bound object variable

What is a Dispatch Interface?

How does the LET statement work?

Early-binding and Late-binding