Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
making sure a cell in an array is not duplicated Zombie0635 Excel Discussion (Misc queries) 2 August 28th 09 12:19 AM
Quickest Way of making an Array WhytheQ Excel Programming 6 May 20th 06 07:07 PM
Making Array Formula, please assist! Macinslaw Excel Worksheet Functions 3 October 11th 05 09:46 PM
Making array from range René[_2_] Excel Programming 2 October 4th 05 06:28 AM
Making progress with array functions, another two questions Don Taylor Excel Programming 3 January 4th 05 08:30 PM


All times are GMT +1. The time now is 07:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"