ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing Array to function (https://www.excelbanter.com/excel-programming/442449-passing-array-function.html)

Gian

Passing Array to function
 
Hi All,

I have defined the following variables type:

Type XXX
Var1 as double
Var2 as double
End Type

Public XYZ(10) as XXX

How can I pass the array XYZ to a function?

Funcationname(XYZ ) doesn't seems like working

Thanks.

--
Gian

Gian

Passing Array to function
 
Thanks SteAXA. I know what I did wrong.
--
Gian


"SteAXA" wrote:

I try this:

Type XXX
Var1 As Double
Var2 As Double
End Type

Public XYZ(10) As XXX

Sub macro_1()
XYZ(0).Var1 = 11
XYZ(0).Var2 = 12
XYZ(1).Var1 = 21
XYZ(1).Var2 = 22
XYZ(2).Var1 = 31
XYZ(2).Var2 = 32

TryToPass XYZ

End Sub

Function TryToPass(ByRef aaa() As XXX)
Dim ncount As Integer
Dim Toshow
ncount = 0
While Not (ncount 10)
Toshow = aaa(ncount).Var1 & " " & aaa(ncount).Var2
MsgBox Toshow
ncount = ncount + 1
Wend
End Function

It seems to work well, maybe i don't understand your problem.


SteAXA

Passing Array to function
 
That's ok, good work!
Ste'


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com