This example shows how you can embed a LANSA ActiveX reusable part to a Visual Basic form. The LANSA ActiveX component is the grid showing skill details for an employee:
Source that makes up this example:
Name | Type | Description |
|---|---|---|
AXPANELA | Visual LANSA Component | Visual LANSA Source |
Project1 | Visual Basic Project | Project Definition |
Form1 | Visual Basic Form | Visual Basic - Code |
Session.cfg | Configuration file | Session Configuration (Session.cfg) |
Refer to Embed a Reusable Part for the source code.
Step 1. Add the Visual LANSA Component
In this step you create the LANSA ActiveX reusable part containing a grid:
To create the LANSA ActiveX control:
- Open the LANSA editor and create a new component named AXPANELA, type Reusable Part.
- Copy and paste into the Visual LANSA Editor the source code from Case 2 - Visual LANSA Source.
- Use the Set ActiveX Attributes command in the ribbon.
- Compile the component.
Step 2. Add the Visual Basic Form
In this step you create the Visual Basic form which contains the LANSA ActiveX control:
To create the form:
- Complete the General Setup Tasks to create a new Visual Basic project.
- Close Visual Basic.
- Start Notepad, open the form (Form<n>.frm) created in the General Setup Tasks.
- Replace the code in Notepad with the source code from Case 2 - Visual Basic - Object, then save it.
- 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 2 - Visual Basic - Code, then Save it.
- Right-click in the Visual Basic toolbox and select Components from the popup menu.
- Scroll down and check LANSA.AXPANELA. This will add an icon for the AXPANEL control to the toolbox.
- Click on the AXPANELIA icon to select it and on the form drag out a rectangle and release the left mouse key to include the LANSA ActiveX control to the form:
View the properties of the ActiveX control and change the name from AXPANELA1 to AXPANELA.
Notes:- If your Toolbox is not displayed, click View then Toolbox.
- To view the forms user interface design, Click View, then click Object from the Menu or by using the Project Pane.
- 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.
You can now view the sample Personnel data by executing the program and typing in an Employee Number, then clicking on Show.



