Results 1 to 4 of 4

Thread: Simple question on classes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 1999
    Location
    Kempton Park, Guateng, South Africa
    Posts
    24
    I have a public function in a class module but this function returns a value of a user defined type. This causes a error saying that it's not possible to have a user defined type as a parameter of a public method.

    Why is it not possible to have a user defined type in a class module without having to declare the function as private? I want this function to be exposed. The function header is as follows:

    Public Function GetRGB(RGBValue As Long) As RGBTRIPLE
    "He who laughs at a question is not worth being asked"

    RavenCrow

  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    Try setting the User Defined Type as a paramater to the function, like this:

    Public Sub GetRGB(RGBValue As Long, MyType As RGBTRIPLE)

    In VB UDTs arepassed by reference, meaning that you pass the the stucture as an argument that you want to be populated by your procedure. When the procedure returns the UDT will be populated.

    Hope this is what you wanted.

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    There's some hiddeous technical reason why you can't pass out UDTs also, it's considdered bad practice to expose a UDT anyway, expose the red green and blue values as properties and expose a long representing the RGB Triple (Use the CopyMemory API inside your class to copy the RGB tripple into a long.)

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 1999
    Location
    Kempton Park, Guateng, South Africa
    Posts
    24
    Thanks for the advice guys, it's very much appretiated
    "He who laughs at a question is not worth being asked"

    RavenCrow

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