Visual Basic 6 Code Sample

Within Visual Basic 6, select ProjectComponents, then Browse for the .dll of the wrapper object in order to include the objects definition in the project.

For details about the object parameters, see Sample IDL Object.

Initiation Without Parameters in Visual Basic 6

Use the following code to initialize the object with no parameters.

Private Sub MyRoutine 
 
   Dim oFoo As IDLexFoo 
   Set oFoo = New IDLexFoo 
     
   On Error GoTo ErrorHandler 
 
   oFoo.CreateObject 0, 0, 0 
      ' use object here... 
   Return 
     
ErrorHandler: 
   If Not oFoo Is Nothing Then 
      Debug.Print oFoo.GetLastError 
   End If 
 
End Sub 

Initiation with Parameters in Visual Basic 6

Use the following code to initialize the object with its three parameters (a string, a 32-bit long value, and an array which has two rows and three columns, containing 32-bit long values).

Const PARMFLAG_CONST As Integer = &H1 
Const PARMFLAG_CONV_MAJORITY As Integer = &H4000 
 
Private Sub MyRoutine 
 
   Dim oFoo As IDLexFoo 
 
   Dim parmStr As String 
   Dim parmVal As Long 
   Dim parmArr(1, 2) As Long 
 
   Dim argc As Long 
   Dim argv(2) As Variant 
   Dim argpal(2) As Long 
 
   parmStr = "I am a string parameter" 
   parmVal = 24 
   parmArr(0, 0) = 10: parmArr(0, 1) = 11: parmArr(0, 2) = 12 
   parmArr(1, 0) = 20: parmArr(1, 1) = 21: parmArr(1, 2) = 22 
     
   argc = 3 
   argv(0) = parmStr: argpal(0) = PARMFLAG_CONST 
   argv(1) = parmVal: argpal(1) = PARMFLAG_CONST 
   argv(2) = parmArr: argpal(2) = PARMFLAG_CONST + _ 
      PARMFLAG_CONV_MAJORITY 
    
   Set oFoo = New IDLexFoo 
    
   On Error GoTo ErrorHandler 
 
   oFoo.CreateObject argc, argv, argpal 
      ' use object here... 
   Return 
     
   ErrorHandler: 
      If Not oFoo Is Nothing Then 
         Debug.Print oFoo.GetLastError 
      End If 
 
End Sub