Making array in DLL available in VBA?
Hello,
I try to populate a 2 dims array in VBA with a 2 dims created in DLL(via VB6). Declaring in Vb6 the array as public is rejected. Help please Avi |
Making array in DLL available in VBA?
A bit vague on detail, I gess you are trying to make an array Public in a
class module of your dll. Can't do that in VB or VBA. One of many ways - ' Class1, public class in the dll or simply in VBA for testing Dim mnArr(0 To 5) As Long Public Function PopArray(n As Long) For i = 0 To UBound(mnArr) mnArr(i) = n * i Next End Function Public Function GetArray(theArray() As Long) theArray = mnArr End Function ' normal module in VB or VBA Dim c As Class1 Sub Test() FillArray GetArray ClearUp End Sub Sub FillArray() If c Is Nothing Then Set c = New Class1 c.PopArray 10 End Sub Sub GetArray() Dim anArray() As Long If c Is Nothing Then Exit Sub c.GetArray anArray For i = LBound(anArray) To UBound(anArray) Debug.Print i, anArray(i) Next End Sub Sub ClearUp() Set c = Nothing ' destroy the class (and/or quit the dll) End Sub Regards, Peter T "avi" wrote in message ps.com... Hello, I try to populate a 2 dims array in VBA with a 2 dims created in DLL(via VB6). Declaring in Vb6 the array as public is rejected. Help please Avi |
Making array in DLL available in VBA?
Hello peter,
Thanks again for your help. As it seems quite problematic and difficult to reference everything in VB6, i decided to rewrite all my VBA code in VB6 with only a reference to the active workbook, as it is an add-in. The decision seems very promising for the moment Thanks again Avi |
All times are GMT +1. The time now is 06:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com