Results 1 to 11 of 11

Thread: Assign a UDT to a variant array?

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Assign a UDT to a variant array?

    I am trying (in a .bas module) to assign a UDT (declared in the same module) to a variant array (in the same module). I get this error:

    "You attempted to use a public user defined type as a parameter or return type for a public procedure of a class module, or as a field of a public user defined type. Only public user defined types that are defined in a public object module can be used in this manner. "


    *** does that all mean?? And how do I resolve this?
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    mabye try making the UDT public?
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Done that. Don't work.
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    What kind of project is it, a DLL?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Just a McRegular .exe.


    VB Code:
    1. 'Declarations:
    2. 'Single choice question
    3. Private Type QuestionSC
    4.     qtQuestionType As QuestionType
    5.     strQuestion As String
    6.     audFilename As String
    7. End Type
    8.  
    9. 'Question list
    10. Private varQuestionList As Variant
    11.  
    12.  
    13. Sub BuggeredSub()
    14.     Dim qtSCQuestion As QuestionSC
    15.     qtSCQuestion.qtQuestionType = QT_SINGLE_CHOICE
    16.     varQuestionList(0) = qtSCQuestion
    17. End Sub


    That's the Gist of it. The above is in a .bas module.
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  6. #6

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    And no, changing all the above to public makes no difference.
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Hmmm, the only error I got was that private Types can't be coerced to Variants.

    I give up.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  8. #8

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Originally posted by crptcblade
    Hmmm, the only error I got was that private Types can't be coerced to Variants.

    I give up.



    Yeah, that's the error message. The above was from the Help on that error, apologies. Nonetheless, it doesn't frickin work anyway... stoopid precompiler...
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  9. #9
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Yeah, to do what you want, the Type has to be declared as Public in an object module, like a class or uc. Why can't you have a QuestionSC array?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  10. #10

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    BEcause there are at least 2 other types I want in that array...

    I'm trying to make a quick hard-coded solution for an 'exam' of sorts.

    I also tried putting it in a class, and it still gave me the same error...
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  11. #11

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Can I have a public class in a standard .exe?
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

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