Need help passing an array as an argument

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I wanted to ask for some quick help. For the life of me I cannot figure out why the following code will not work... Any hints/comments?

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'In a class module written in VB6 I have the following paired property procedure

Public Property Get SomeArray( ) As String( )

SomeArray = mstrHiddenArray

End Property

Public Property Let SomeArray(ByRef TempArray( ) As String)

mstrHiddenArray = TempArray

End Property
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Inside an Excel VBA module I call the above property procedure:

Call MyObject.SomeArray(gstrGlobalArray)

'Note: gstrGlobalArray is a TWO-dimensional string array...

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

In the Excel VBA module where I invoke the property procedure I get an "Invalid Use of Property" error message... What do you think? Forget programming & get another career??? lol

Anyways, anything anybody could contribute would be helpful...

Thanks,

blc
 
Only a variant can hold an array. If you dim somearray as a string array,
then I wouldn't think you could assign another array to it.

--
Regards,
Tom Ogilvy



blc said:
Hello all,

I wanted to ask for some quick help. For the life of me I cannot figure
out why the following code will not work... Any hints/comments?
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'In a class module written in VB6 I have the following paired property procedure

Public Property Get SomeArray( ) As String( )

SomeArray = mstrHiddenArray

End Property

Public Property Let SomeArray(ByRef TempArray( ) As String)

mstrHiddenArray = TempArray

End Property
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Inside an Excel VBA module I call the above property procedure:

Call MyObject.SomeArray(gstrGlobalArray)

'Note: gstrGlobalArray is a TWO-dimensional string array...

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

In the Excel VBA module where I invoke the property procedure I get an
"Invalid Use of Property" error message... What do you think? Forget
programming & get another career??? lol
 
This works (in Excel) - you can experiment with this and see if you can get
a specific solution:

In Module:

Sub Tester1()
Dim myobj As pTest
Dim varr(1 To 2, 1 To 2) As String
varr(1, 1) = "ABC"
varr(2, 1) = "DEF"
varr(1, 2) = "GHI"
varr(2, 2) = "JKL"
Set myobj = New pTest
myobj.SomeArray = varr
varr1 = myobj.SomeArray
For i = LBound(varr1, 1) To UBound(varr1, 1)
For j = LBound(varr1, 2) To UBound(varr, 2)
Debug.Print i, j, varr1(i, j)
Next
Next
End Sub

in Class Module

Private mstrHiddenArray As Variant
Public Property Get SomeArray()

SomeArray = mstrHiddenArray

End Property

Public Property Let SomeArray(ByRef TempArray)

mstrHiddenArray = TempArray

End Property
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top