Declare dll function error

XonsArgi

New Member
Joined
Apr 18, 2016
Messages
20
Hello guys. I'm having trouble tryin to declare a function from a dll, in a test case I'm not bein' able to use a function that i made using visual basic in a dll.
Error 453 gets on my way no matter what i do.


The code in the VBA on excel is:
Code:
Declare Function TestReturn Lib "[I](Path to dll folder)\JMSys.dll[/I]" () As Double

Sub teste()
    MsgBox TestReturn
End Sub

The code usin' in the dll is:
Code:
Public Module LinearAlgebra
    Public Function ModulusOfVector(ByRef x As Double()) As Double


        Dim sum As Double
        Dim i As Long


        For i = LBound(x) To UBound(x)
            sum = sum + x(i) ^ 2
        Next i


        Return sum ^ (0.5)


    End Function
    Public Function TestReturn(x As Double) As Double
        TestReturn = 3
    End Function
End Module

The code on Visual Basic works for sure cause I tested on other application created in VB

Any lights?
 
Did this not help?
Code:
Option Compare Text 
Option Strict Off 
 'Imports WP = WordPerfect.PerfectScript
Imports System 
Imports System.Runtime.InteropServices 
Imports WIN32 = Microsoft.Win32 
 
 
<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)> _ 
Public Class Multiply 
 
Public Function MultiplyBy2(ByVal D As Double) As Double 
    Return D * 2 
End Function 
 
Public Function MultiplyBy4(ByVal D As Double) As Double 
    Return D * 4 
End Function 
 
 
<ComRegisterFunctionAttribute()> _ 
Public Shared Sub RegisterFunction(ByVal type As Type) 
WIN32.Registry.ClassesRoot.CreateSubKey(GetSubkeyName(type)) 
End Sub 
 
<ComUnregisterFunctionAttribute()> _ 
Public Shared Sub UnregisterFunction(ByVal type As Type) 
WIN32.Registry.ClassesRoot.DeleteSubKey(GetSubkeyName(type), False) 
End Sub 
 
Private Shared Function GetSubkeyName(ByVal type As Type) As String 
Dim S As New System.Text.StringBuilder() 
S.Append("CLSID\{") 
S.Append(type.GUID.ToString().ToUpper()) 
S.Append("}\Programmable") 
Return S.ToString() 
End Function 
 
End Class
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top