Using MS Access/Excel 32bit & 64 bit while using MC 64 bit
Posted: Sep 14 2017
I just found out that MS-Access 64 bit can be used with the MC 64 bit dll for the purpose of sending/receiving data to/from MC 64 bit. For any who may be interested I included below the MS-Access code that passed the the test which was done by someone who has the 64 bit MS-Access (I will be buying it soon) . The "PtrSafe" command is the command that allows the DLL function definitions to be accepted by the 64 bit MS-Access. If you want to run these with MS-Access 32 bit you need to remove the PtrSafe command. In the example below (for the purpose of testing) the dll was renamed "GlobalVariable_64bit.dll" and located in the C:\ directory. You will probably want to use the original dll which is located in the directory that MC uses and point these declare functions at it. I had to create my own wrapper functions in MC to cover off every possible data type that is available with the GVs (boolean, double, integer, float and string). I decided to do this since I figure I am going to run out of named global variables if I am only using (int, float and string). In other words I can scan more stocks with all 5 types available. Creating some of the ones that were missing was a bit of a challenge so if anyone is having trouble creating some of the ones that are missing let me know and I will add them to this thread.
Code: Select all
Option Compare Database
Option Explicit
Private Declare PtrSafe Function GV_GetNamedBool Lib "C:\GlobalVariable_64bit.dll" _
(ByVal intOther As Boolean, ByVal strElementLoc As String) As Boolean
Private Declare PtrSafe Function GV_SetNamedBool Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As Boolean) As Long
Private Declare PtrSafe Function GV_GetNamedDouble Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intOther As Double) As Double
Private Declare PtrSafe Function GV_SetNamedDouble Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As Double) As Long
Private Declare PtrSafe Function GV_GetNamedInt Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intOther As Single) As Long
Private Declare PtrSafe Function GV_SetNamedInt Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As Long) As Long
Private Declare PtrSafe Function GV_GetNamedFloat Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intOther As Single) As Single
Private Declare PtrSafe Function GV_SetNamedFloat Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As Single) As Long
Private Declare PtrSafe Function GV_GetNamedString Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal strOther As String) As String
Private Declare PtrSafe Function GV_SetNamedString Lib "C:\GlobalVariable_64bit.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As String) As Long
'=========================================================================================
'START: Booleans
Public Function A_GV_GetNamedBool64(strName As String, blnErrorCode As Boolean) As Boolean
A_GV_GetNamedBool64 = GV_GetNamedBool(blnErrorCode, strName)
End Function
Public Function A_GV_SetNamedBool64(strName As String, dblGVvalue As Boolean) As Long
A_GV_SetNamedBool64 = GV_SetNamedBool(strName, dblGVvalue)
End Function
'=========================================================================================
'START: Doubles
Public Function A_GV_GetNamedDouble64(strName As String, lngErrorCode As Long) As Double
A_GV_GetNamedDouble64 = GV_GetNamedDouble(strName, lngErrorCode)
End Function
Public Function A_GV_SetNamedDouble64(strName As String, dblGVvalue As Double) As Long
A_GV_SetNamedDouble64 = GV_SetNamedDouble(strName, dblGVvalue)
End Function
'=====================================================================================
'START: Integers
Public Function A_GV_GetNamedInt64(strName As String, lngErrorCode As Long) As Long
A_GV_GetNamedInt64 = GV_GetNamedInt(strName, lngErrorCode)
End Function
Public Function A_GV_SetNamedInt64(strName As String, lngGVvalue As Long) As Long
A_GV_SetNamedInt64 = GV_SetNamedInt(strName, lngGVvalue)
End Function
'=========================================================================================
'START: Floats
Public Function A_GV_GetNamedFloat64(strName As String, lngErrorCode As Long) As Single
A_GV_GetNamedFloat64 = GV_GetNamedFloat(strName, lngErrorCode)
End Function
Public Function A_GV_SetNamedFloat64(strName As String, sngGVvalue As Single) As Long
A_GV_SetNamedFloat64 = GV_SetNamedFloat(strName, sngGVvalue)
End Function
'===========================================================================================
'START: Strings
Public Function A_GV_GetNamedString64(strName As String, strErrorCode As String) As String
A_GV_GetNamedString64 = GV_GetNamedString(strName, strErrorCode)
End Function
Public Function A_GV_SetNamedString64(strName As String, strGVvalue As Variant) As Long
A_GV_SetNamedString64 = GV_SetNamedString(strName, strGVvalue)
End Function