Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a UDT to a procedure -"Expected array" error

Status
Not open for further replies.

BigInch

Petroleum
Joined
Jun 21, 2006
Messages
15,161
Location
GB
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?

BigInch[worm]-born in the trenches.
 
Thanks for reading this, but no worries. I got it.

'main code,
Call transform_xyz(transform)
------------------------------
'module
Public Sub transform_xyz(ByRef transform As transforms)
'body
End Sub

BigInch[worm]-born in the trenches.
 
When your;

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top