Results 1 to 3 of 3

Thread: [RESOLVED] DLL + ByRef parameters

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2011
    Posts
    31

    Resolved [RESOLVED] DLL + ByRef parameters

    Hi everyone,

    I would like to know if it is possible to create routines with ByRef parameters in a class module offered by a DLL.

    I have made a test by creating a routine with a ByRef boolean parameter in a class module from a VB6 DLL ActiveX project. Then, I called the routine passing a local boolean variable from a VB6 client project. But, the boolean variable is unchanged after the routine execution.

    Thanks for your future help.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: DLL + ByRef parameters

    Not sure how you did it so here is a quick example of how it's done:
    Code:
    'dll project
    Option Explicit
    
    Public Sub Test(ByRef a As String, ByRef b As Boolean)
        a = a & "b"
        b = Not b
    End Sub
    
    'standard project
    Private Sub Command1_Click()
    Dim oClass As myDll.Class1
    Dim a As String
    Dim b As Boolean
    
        a = "a"
        b = True
        
        Set oClass = New myDll.Class1
        oClass.Test a, b
        
        Debug.Print a; "; "; b    '<<< output is "ab; False"
    
    End Sub
    As you can see both parameters were changed.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2011
    Posts
    31

    Re: DLL + ByRef parameters

    I performed a new test and the ByRef mechanism works. I really don't know why my first test failed. Thanks for your help anyway.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width