Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Need help passing an array as an argument

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 procedu

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help passing an array as an argument

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" wrote in message
...
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 procedu

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help passing an array as an argument

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

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
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" wrote in message
...
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 procedu

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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Need help passing an array as an argument

Thank you Tom, I will give it a try.

Thanks again,

blc


"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
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" wrote in message
...
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 procedu

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






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
Passing a UDF as an argument to a UDF puff Excel Discussion (Misc queries) 3 February 23rd 06 09:46 PM
VBA - Passing a FUNCTION as an Argument James B Excel Programming 3 February 18th 04 03:42 PM
Passing range as argument Jan Kronsell[_2_] Excel Programming 3 September 3rd 03 12:31 PM
Passing an Array of User-Defined Type to an Argument of a Function Tushar Mehta[_6_] Excel Programming 0 August 17th 03 06:43 PM
Passing an argument to a quote Zach Excel Programming 1 July 25th 03 01:00 AM


All times are GMT +1. The time now is 09:40 PM.

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"