Passing a UDT to a procedure -"Expected array" error
Passing a UDT to a procedure -"Expected array" error
(OP)
I obviously don't know enough about passing variables to procedures and am having a difficult time with passing an array. I have defined a user type named "transforms" in a module as follows,
Type transforms
tx As Double
ty As Double
tz As Double
rx As Double
ry As Double
rz As Double
End Type
and,
Declared transform as transforms, also in the module.
In main code I define the values of the first transformation and attempt to pass them to the transform)xyz procedure like so,
transform.tx = Val(Text1(0).Text)
transform.ty = Val(Text1(1).Text)
transform.tz = Val(Text1(2).Text)
transform.rx = Val(Text2(0).Text)
transform.ry = Val(Text2(1).Text)
transform.rz = Val(Text2(2).Text)
pt = 1
transform_xyz pt, transform()
to a public sub,
Public Sub transform_xyz(pt, xyz)
I get an "Expected array" error message.
On some variations I have tried, I get a "Ony user-defined types defined in a pubic object module can be coerced to or from a variant or passed to late-bound functions."
From the above, I surmise I must somehow define a procedure object or something, but admit its beyond my limited knowledge to attempt that task.
Anybody have some ideas about how I should do this thing?
Type transforms
tx As Double
ty As Double
tz As Double
rx As Double
ry As Double
rz As Double
End Type
and,
Declared transform as transforms, also in the module.
In main code I define the values of the first transformation and attempt to pass them to the transform)xyz procedure like so,
transform.tx = Val(Text1(0).Text)
transform.ty = Val(Text1(1).Text)
transform.tz = Val(Text1(2).Text)
transform.rx = Val(Text2(0).Text)
transform.ry = Val(Text2(1).Text)
transform.rz = Val(Text2(2).Text)
pt = 1
transform_xyz pt, transform()
to a public sub,
Public Sub transform_xyz(pt, xyz)
I get an "Expected array" error message.
On some variations I have tried, I get a "Ony user-defined types defined in a pubic object module can be coerced to or from a variant or passed to late-bound functions."
From the above, I surmise I must somehow define a procedure object or something, but admit its beyond my limited knowledge to attempt that task.
Anybody have some ideas about how I should do this thing?
BigInch-born in the trenches.
http://virtualpipeline.spaces.msn.com
RE: Passing a UDT to a procedure -"Expected array" error
'main code,
Call transform_xyz(transform)
------------------------------
'module
Public Sub transform_xyz(ByRef transform As transforms)
'body
End Sub
BigInch-born in the trenches.
http://virtualpipeline.spaces.msn.com
RE: Passing a UDT to a procedure -"Expected array" error
Public Sub transform_xyz(ByRef transform As transforms)
'body
End Sub
is in a Module your code is fine; when it is in a Form use;
Friend Sub transform_xyz(ByRef transform As transforms)
'body
End Sub
vb6 assumed
regards Hugh
RE: Passing a UDT to a procedure -"Expected array" error
"Friend", Interesting; I'll try that.
Thanks.
BigInch-born in the trenches.
http://virtualpipeline.spaces.msn.com