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:
- Dynamically build and manage objects using collections
- Invoke business rules from the LANSA repository
- Handle messages issued from LANSA
Source that makes up this example:
Name | Type | Description |
|---|---|---|
AXOBJECTA | Visual LANSA Component | Reusable Part AXOBJECTA |
AXOBJECTB | Visual LANSA Component | Reusable Part AXOBJECTB |
Project1 | Visual Basic Project | Project Definition |
Form1 | Visual Basic Form | Visual Basic - Code |
Session.cfg | 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.
- Open the LANSA editor and create a new component named AXOBJECTA, type Reusable Part.
- Copy and paste into the Visual LANSA Editor the source code for Reusable Part AXOBJECTA into the component.
- Use the Set ActiveX Attributes command in the ribbon.
This step exposes the Visual LANSA component as an ActiveX Control. - Repeat steps 1 to 3 for component Reusable Part AXOBJECTB.
- 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:
- Complete the General Setup Tasks to create a new Visual Basic project.
- Close Visual Basic.
- Start Notepad and open the form (Form<n>.frm) created in the General Setup Tasks.
- Replace the code in Notepad the source code from Case 3 - Visual Basic - Object, then Save.
- Open the Project (Project<n>.vbp) in your Visual Basic development environment.
- Open the form (Form<n>.frm)
- Replace the code with the source code from Case 3 - Visual Basic - Code, then Save.
- Select the Project menu and then the References…option.
Scroll down and select LANSA.AXOBJECTA and LANSA.AXOBJECTB. Click OK. This will add a Reference for each object to the project.
Notes:- If your Toolbox is not displayed, click View then Toolbox.
- To view the form's user interface, Click View, then click Object from the Menu or by using the Project Pane.
- If you have an empty list at runtime then check the view style, it should be lvwReport
- You do not need to add the LANSA ActiveX business objects to the toolbox or the form.
- In the LOAD routine modify the login script below to your requirements. For example:
Call ConnectToLansa("user1", "mypassword", "c:\ActiveXTests\session.cfg") - Save, then compile the Visual Basic Project using the Make Project<n>.exe option in the File menu.
