Adding code to your Microsoft Visual Basic Project

The Example1.prj project will compile and run, and present an empty dialog box.

This section describes how to add code to this project to make a very simple IBM® Cognos® TM1® application.

Procedure

  1. Open the Example1.prj project from Windows Explorer.
  2. Open the project window, if it is not open already, by choosing View, Project Explorer.
  3. In the project window, highlight Project1 (Example.vbp). Right-click, and choose Add, Module.
  4. Click the Existing tab, and use the file search dialog to find TM1API.BAS.
  5. Double-click the TM1API.BAS file to add it to your project.
  6. Choose View, Code from the Microsoft Visual Basic menus. A code window appears.
  7. Enter the following code in this window:
    Option Explicit

    This line forces your variables to be strictly typed by MicrosoftVisual Basic. It sometime help to make debugging easier.

  8. Click the option button containing the word (General). Choose Form. The Form_Load subroutine opens.
  9. Enter the following code into the Form_Load subroutine:
    Dim hUser As Long
    TM1ApiInitialize()
    hUser = TM1SystemOpen()
    TM1SystemAdminHostSet hUser, "AdminHost"

    This code initializes the API, and calls TM1SystemAdminHostSet. Both of these functions must be called in the order shown in any TM1 API program.

    Note: The server name established in the second argument to TM1SystemAdminHostSet will have to be a TM1 Admin Host in your network. The name AdminHost is only an example.

    If your program now compiles and run successfully, your project is properly configured. You are ready to write a program that logs into a TM1 server. The following section describes that code.