×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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?

BigInchworm-born in the trenches.
http://virtualpipeline.spaces.msn.com

Replies continue below

Recommended for you

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

(OP)
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

BigInchworm-born in the trenches.
http://virtualpipeline.spaces.msn.com

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

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

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

(OP)
Those error messages sounded worse than they turned out to be.

"Friend", Interesting; I'll try that.  
Thanks.

BigInchworm-born in the trenches.
http://virtualpipeline.spaces.msn.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close