Announcement

Collapse
No announcement yet.

Problem calling a Sub from a DLL but not a Function in VB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem calling a Sub from a DLL but not a Function in VB

    I have written a DLL in PowerBasic that I want to be accessible from a VB application. If I create a function call in the DLL, I have no problems with calling that function from VB. If I change the function to a Sub Routine, I always receive an error in VB stating:

    Code:
         Runtime Error ‘453'
         Can't find entry DLL entry point MyCall in D:\TestCall.DLL
    Here is the PB code:

    Function -- Works Fine
    Code:
    #COMPILE DLL "D:\TestCall.DLL"    '// Compile to DLL rather than EXE
    #DIM ALL                          '// Forced to declare variables before use
    #DEBUG ERROR OFF                  '// Use to Toggle Error
    
    FUNCTION MyCall ALIAS "MyCall" (BYVAL L1 AS LONG, BYREF L2 AS LONG) EXPORT AS INTEGER
        L2 = L1
    END FUNCTION
    Sub -- Does NOT work .. Generates Error
    Code:
    #COMPILE DLL "D:\TestCall.DLL"    '// Compile to DLL rather than EXE
    #DIM ALL                          '// Forced to declare variables before use
    #DEBUG ERROR OFF                  '// Use to Toggle Error
    
    SUB MyCall ALIAS "MyCall" (BYVAL L1 AS LONG, BYREF L2 AS LONG)
        L2 = L1
    END SUB
    Here is the VB code:

    Code:
    Private Declare Sub MyCall Lib "D:\TestCall.DLL" (ByVal L1 As Long, ByRef L1 As Long)
    
    Private Sub Command1_Click()
        Dim yy  As Integer
        Dim LL1 As Long
        Dim LL2 As Long
        LL1 = 10
        LL2 = 15
        Call MyCall(LL1, LL2)
    End Sub

    Any ideas or suggestions?

    Andrew Peskin
    [email protected]

    ------------------

  • #2
    After speaking with Tech Support, I realized that you need to include an EXPORT after the sub declaration, once that was onde, everything worked fine.

    Andrew

    ------------------

    Comment

    Working...
    X