Results 1 to 10 of 10

Thread: Trouble! Array of Array of UDT

  1. #1

    Thread Starter
    Member Mythrandil's Avatar
    Join Date
    Mar 2006
    Posts
    55

    Trouble! Array of Array of UDT

    Hey all

    Im having trouble defining an array of an array of user defined types.

    So far i have:

    VB Code:
    1. Public Type POINTAPI
    2.     X As Long
    3.     Y As Long
    4. End Type
    5. Public Points()         As POINTAPI
    6. Public Objects()       As Variant

    VB Code:
    1. Private Sub Form_Load()
    2.     Objects = Array()
    3.     ReDim Points(0) As POINTAPI
    4.     ReDim Objects(0) As Variant
    5. End Sub
    VB Code:
    1. Private Sub cmdcomplete_Click()
    2.     Objects(UBound(Objects)) = Points
    3.     ReDim Objects(UBound(Objects) + 1)
    4.     Erase Points
    5.     ReDim Points(0)

    Basicly points is an array of coords that defines a polygon. When cmdcomplete is clicked this polygon is added to the objects array, and the points array initialized to create another polygon ;d

    Thanks for any help

    /edit, compiler doesn't like line: Objects(UBound(Objects)) = Points

    Stating: Only UDT defined in public object modules can be coerced to or from a variant.
    Last edited by Mythrandil; Apr 30th, 2006 at 08:32 AM. Reason: add error

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Trouble! Array of Array of UDT

    Try
    VB Code:
    1. Objects() = Points()
    and have
    VB Code:
    1. Objects() As POINTAPI
    instead of Variants
    Last edited by Andrew G; Apr 30th, 2006 at 09:01 AM.

  3. #3

    Thread Starter
    Member Mythrandil's Avatar
    Join Date
    Mar 2006
    Posts
    55

    Re: Trouble! Array of Array of UDT

    Hey thanks for the reply.

    I get a type mismatch error on the same line as before doing it your way !

  4. #4

    Thread Starter
    Member Mythrandil's Avatar
    Join Date
    Mar 2006
    Posts
    55

    Re: Trouble! Array of Array of UDT

    Sorry for bumping but really need help with this!!

    Seems such a trivial thing to do i don't understand why it isn't so simple

  5. #5
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Re: Trouble! Array of Array of UDT

    How about this way
    VB Code:
    1. objects(UBound(objects)) = points(UBound(points))
    Last edited by Bearnerd; Apr 30th, 2006 at 12:10 PM.

  6. #6

    Thread Starter
    Member Mythrandil's Avatar
    Join Date
    Mar 2006
    Posts
    55

    Re: Trouble! Array of Array of UDT

    That would put the last element of the points array in objects which isn't my aim. I want to put the whole array points in an element of objects.

  7. #7

  8. #8

    Thread Starter
    Member Mythrandil's Avatar
    Join Date
    Mar 2006
    Posts
    55

    Re: Trouble! Array of Array of UDT

    Yes after some research i realised that is my only option. Which is a mighty kick in the crutch, as i need to pass the points to API's like polygon which require a UDT so i presume i need to convert them from dummy classes and back again every time i require these apis, which is very inefficient and nasty!!!!

  9. #9

  10. #10

    Thread Starter
    Member Mythrandil's Avatar
    Join Date
    Mar 2006
    Posts
    55

    Re: Trouble! Array of Array of UDT

    but everytime my image refreshs i will have to pull all data out of the dummy classes back into udts to pass to polygon api's, just annoying is all.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width