How to use external dll function

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
Hi

A GlobalVariable.dll as been created to exchange information between a trading software and the external word.

Function like GVSetString is available:
GVSetString( NewGlobalString, "This string will be strore in the NewGlobalString variable")

What is the process to get access to an external dll.
The file is :C\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll

Again any help appreciated because I'm :confused:

Martin
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Either set a reference to the dll in the References dialog, or use the Declare statement with the Function/sub name.
 
Upvote 0
Hello rorya

- Set as reference: does not work.

I will try to: use the Declare statement with the Function/sub name.

Never done it, but I will look in the help.

Martin
 
Upvote 0
Here is my un working code. I got a message that the file "C:\Program Files (x86)\TS Support\GlobalVariable.dll" is not found

Any Idea why it fail?

Code:
Option Explicit

Declare Function GVGetInteger Lib "C:\Program Files (x86)\TS Support\GlobalVariable.dll" (ByVal Price As Double)
Declare Function GVGetString Lib "C:\Program Files (x86)\TS Support\GlobalVariable.dll" (ByVal Val As Integer)

Sub UseGlobalVariable()
   Dim Price As Double
   Dim string2 As String

   Price = GVGetInteger(0)     '    Location of an integer
   string2 = GVGetString(3)    '    Location of a string
End Sub
 
Upvote 0
First thing - are you sure that path is correct?
 
Upvote 0
The address is good, as far as I know since I copied it from Windows Explorer.

I will try to seek more information about this collection. It is mention that it is accessible via Visual Basic. But I have no example to work with.

Martin
 
Upvote 0
Is that the exact error message you get?
 
Upvote 0
Rorya, Indeed, I had an error in the addressing. The file was on to places on the disk

Now, my new error message is translated by:

Error 49: DLL calling convention erroneus

Code:
Public DLLString  As String
Public Val As Integer

Option Explicit



Declare Function GV_GetInteger Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal Val As Integer)
Declare Function GV_GetString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal Val As Integer)
'


Sub UseGlobalVariable()
Dim Price As Double
Dim string2 As String
Dim va
Price = Price + 1

Price = GV_GetInteger(Val)
string2 = GV_GetString(3)
End Sub

Martin
 
Upvote 0
That sounds like your declaration is wrong, but I can't assist with that as I don't use that software. I would suspect that your Integer variables should be Long though.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

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