×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-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!

*Tek-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

Cannot pass array (user defined type) to subprocedure!

Cannot pass array (user defined type) to subprocedure!

Cannot pass array (user defined type) to subprocedure!

(OP)
My user defined type is "Wireframe" and I get a type mismatch when I try to pass it to my sub.

SUB Draw3D(WF AS WireFrame)

^^^ Here is where the sub starts

In the main code, here is where my array is defined.

DIM Pyramid(5) AS WireFrame


And here I try to call my sub procedure and pass "Pyramid" along with it.  I get a type mismatch error. =(

CALL Draw3D(Pyramid())

Anyone know why it would say that, even though to my eyes it should match as a 'Wireframe' type.

RE: Cannot pass array (user defined type) to subprocedure!

I am having the same problem, and I just came on here to post about it when I saw this post, so I thought I'd post my code here.  My code is a little bit different, but is about the same idea, so I'll post it here:

'''''''''''START CODE

TYPE TEST
 APPLE AS INTEGER
 ORANGE AS INTEGER
END TYPE

DIM XYZ(4) AS TEST

SOMEPROCEDURE XYZ()

SUB SOMEPROCEDURE (XYZ())
 XYZ.APPLE = 4
END SUB

''''''''''''END CODE

I get the same thing, a parameter type mismatch error.

Secondly, if I put the code

COMMON SHARED XYZ() at the top of my code, it will give me a DUPLICATE NAME error on the

DIM XYZ(4) AS TEST

I don't get either of these errors when they're just normal arrays.  (I am using the COMMON SHARED to transfer information between several *.BAS files in one program.)

If anyone could help remedy this, it would be greatly appreciated.

RE: Cannot pass array (user defined type) to subprocedure!

Do you have to say...

SUB Draw3D(WF() AS WireFrame) ...?

also is there an ANY data type you can use (it's been awhile, I might be getting this confused w/ another lang...)

Have Fun, Be Young... Code BASIC
-Josh

http://cubee.topcities.com

RE: Cannot pass array (user defined type) to subprocedure!

Figured out the parameter type mismatch error.

It would still be:

SOMEPROCEDURE XYZ()

But in the sub, it would be

SUB SOMEPROCEDURE (XYZ() AS TEST)

That fixes that.

As for the common shared, it was the same deal, but I had to make sure to put the TYPE set before the COMMON SHARED statement, or it gave me an error that the type was undefined.



As for Teenserve's problem, I think when you go into your sub, you have

SUB Draw3D(WF AS Wireframe)

I think you need to put

SUB Draw3D(Pyramid() AS Wireframe)

RE: Cannot pass array (user defined type) to subprocedure!

(OP)
Thank you, what I changed was the WF to WF() in the top of the sub =)

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

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

Close Box

Join Tek-Tips® Today!

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

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close