ActiveX Example 3 - Use Components as Business Objects

In this example you create and use two non-visual LANSA ActiveX components (business objects) which provide functionality to manage employee and skills information in the LANSA Personnel System demonstration files:

This example shows you how to:

Source that makes up this example:





Visual LANSA Component

Reusable Part AXOBJECTA


Visual LANSA Component

Reusable Part AXOBJECTB


Visual Basic Project

Project Definition


Visual Basic Form

Visual Basic - Code


Configuration file

Session Configuration (Session.cfg)


Refer to Using Components as Business ObjectS for the source code.

Step 1. Add the Visual LANSA Components

In this step you create two non-visual ActiveX LANSA business objects which provide functionality for managing employee information. These objects are used by the Visual Basic form.

1.  Open the LANSA editor and create a new component named AXOBJECTA, type Reusable Part.

2.  Copy and paste into the Visual LANSA Editor the source code for Reusable Part AXOBJECTA into the component.

4.  Use the Set ActiveX Attributes command in the ribbon.

     This step exposes the Visual LANSA component as an ActiveX Control.

5.  Repeat steps 1 to 3 for component Reusable Part AXOBJECTB.

6.  Compile components AXOBJECTB and AXOBJECTA.

Step 2. Add the Visual Basic Form

In this step you create the Visual Basic form which uses the non-visual LANSA ActiveX components to manage employee information in the LANSA Personnel System demonstration files:

1.  Complete the General Setup Tasks to create a new Visual Basic project.

2.  Close Visual Basic.

3.  Start Notepad and open the form (Form<n>.frm) created in the General Setup Tasks.

4.  Replace the code in Notepad the source code from Case 3 - Visual Basic - Object, then Save.

5.  Open the Project (Project<n>.vbp) in your Visual Basic development environment.

6.  Open the form (Form<n>.frm)

7.  Replace the code with the source code from Case 3 - Visual Basic - Code, then Save.

8.  Select the Project menu and then the References…option.

9.  Scroll down and select LANSA.AXOBJECTA and LANSA.AXOBJECTB.  Click OK. This will add a Reference for each object to the project.


10. In the LOAD routine modify the login script below to your requirements. For example:

Call ConnectToLansa("user1", "mypassword", "c:\ActiveXTests\session.cfg")


11. Save, then compile the Visual Basic Project using the Make Project<n>.exe option in the File menu.