Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Source Code ActiveX Example 1 - Visual Basic - Object

     VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Case 1 - VB"
   ClientHeight    =   4425
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5835

...

        LinkTopic       =   "Form1"
   ScaleHeight     =   4425
   ScaleWidth      =   5835
   StartUpPosition =   'Windows Default
   Begin VB.CommandButton cmdClose
      Caption         =   "Close Visual LANSA"
      Enabled         =   0   'False
      Height          =   375
      Left            =   4320
      TabIndex        =   10
      Top             =   3480
      Width           =   1095
   End
   Begin VB.CommandButton cmdUpdate
      Caption         =   "Update"
      Enabled         =   0   'False
      Height          =   375
      Left            =   4320
      TabIndex        =   9
      Top             =   2760
      Width           =   1095

...

        End
   Begin VB.Frame frmEmployeeDetails
      Caption         =   "Employee Details"
      Height          =   2295
      Left            =   120
      TabIndex        =   3
      Top             =   1680

...

           Width           =   3975
      Begin VB.TextBox UemployeeSalary
         BeginProperty DataFormat
            Type            =   1
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0

...

                 FirstWeekOfYear =   0
            LCID            =   3081
            SubFormatType   =   1
         EndProperty
         Height          =   350
         Left            =   1680
         TabIndex        =   6
         Text            =   "Salary"
         Top             =   1560
         Width           =   1215
      End
      Begin VB.TextBox UemployeeGiveName
         Height          =   350
         Left            =   1680
         TabIndex        =   5
         Text            =   "Give Name"
         Top             =   360
         Width           =   1815
      End
      Begin VB.TextBox UemployeeSurname
         Height          =   345
         Left            =   1680

...

              TabIndex        =   4
         Text            =   "Surname"
         Top             =   960
         Width           =   1815
      End
      Begin VB.Label lblSalary
         Caption         =   "Salary:"

...

              Height          =   345
         Left            =   240
         TabIndex        =   8
         Top             =   1560
         Width           =   855
      End
      Begin VB.Label LblName
         Caption         =   "Name:

...

"
         Height          =   345
         Left            =   240
         TabIndex        =   7
         Top             =   360
         Width           =   855
      End
   End
   Begin VB.TextBox uEmployeeNumber
      Height          =   350
      Left            =   1920
      TabIndex        =   1
      Text            =   "A1012"
      Top             =   1080
      Width           =   735
  

...

 End
   Begin VB.CommandButton cmdShowEmployee
      Caption         =   "Show"
      Default         =   -1  'True
      Height          =   350
      Left            =   4320
      TabIndex        =   0
      ToolTipText     =   "Invoke Visual LANSA method to retrieve employee details"
      Top             =   2040
      Width           =   1095
   End
   Begin VB.Label lblexplanation
      Caption         =   "Demonstrates the essentials of how to expose properties, events and methods"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0  

...

 'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   240
      TabIndex        =   11
      Top             =   240
      Width           =  

...

 5295
   End
   Begin VB.Label LblEmployee
      Caption         =   "Employee Number:"
      Height          =   345
      Left            =   360
      TabIndex        =   2
      Top             =   1080
      Width           =   1335
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Source Code ActiveX Example 1 - Visual Basic - Code

     Option Explicit
Public Session    As LANSA_ACTIVEX_LIB.Session

...

      
Private Sub AXFORMA_uEmployeeFound(ByVal uResult As String)
On Error GoTo ErrorHandler
 
If uResult = "OK" Then
    cmdUpdate.Enabled = True
    cmdClose.Enabled = True
    UemployeeGiveName = AXFORMA.UemployeeGiveName
    UemployeeSurname = AXFORMA.UemployeeSurname
    UemployeeSalary = AXFORMA.UemployeeSalary
    Call AXFORMA.ShowForm
Else
    UemployeeGiveName = "Not Found"
    UemployeeSurname = "Not Found"

...


    UemployeeSalary = 0
End If
 
Exit Sub      ' Exit to avoid handler.
ErrorHandler:   ' Error-handling routine.
    MsgBox ("Error :" + Err.Description)
End Sub
 
Private Sub cmdClose_Click()

...


 
Call AXFORMA.uClose
' Unload AXFORMA
 
End Sub
 
Private Sub cmdShowEmployee_Click()
On Error GoTo ErrorHandler
 
' pass the employee number to the vl component method.
    Call AXFORMA.uShowEmployee(uEmployeeNumber)
   
Exit Sub      ' Exit to avoid handler.
ErrorHandler:   ' Error-handling routine.
    MsgBox ("Error :" + Err.Description)
End Sub
 
 
Private Sub cmdUpdate_Click()
 
AXFORMA.UemployeeGiveName = UemployeeGiveName
' notice surname has been set as readonly in the Visual LANSA component
' AXFORMA.UemployeeSurname = UemployeeSurname
If UemployeeSalary = "" Then UemployeeSalary = 0
AXFORMA.UemployeeSalary = UemployeeSalary
 
End Sub
 
Private Sub Form_Load()
On Error GoTo ErrorHandler
 
' login to LANSA using default user, password and session location
    If Session Is Nothing Then
        Call ConnectToLansa("<user name>", "<password>", "<session.cfg path>")
    End If
' now add your component to the current session
    Call Session.AddComponent(AXFORMA.object)

...

             
Exit Sub      ' Exit to avoid handler.
ErrorHandler:   ' Error-handling routine.
    MsgBox ("Error :" + Err.Description)
End Sub
 
Private Sub ConnectToLansa(ByVal username As String, ByVal password As String, ByVal txtlocation As String)
On Error GoTo ErrorHandler
 
    Set Session = New LANSA_ACTIVEX_LIB.Session
   
    ' Set the session configuration file
    Session.ConfigFile = txtlocation
   
    Call Session.SetConnectParam("USER", username)
    Call Session.SetConnectParam("PSPW", password)
   
    Call Session.Connect
   
Exit Sub      ' Exit to avoid handler.
ErrorHandler:   ' Error-handling routine.
    MsgBox ("Error :" + Err.Description)
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
 
    Set Session = Nothing
 
End Sub