Closed Thread
Results 1 to 7 of 7

Loading Custom Data Type ?

  1. #1
    Registered User
    Join Date
    02-09-2005
    Posts
    63

    Loading Custom Data Type ?

    I have the following simple, custom data type:
    Please Login or Register  to view this content.
    And now I want to be able to simply load it from a sheet, e.g.,
    Please Login or Register  to view this content.
    But it does not work. If I throw away my custom data type and just DIM command as variant, it works fine.

    So, how can I load the data SIMPLY, but be able to refer to it using the dot syntax of custom data types?

    **** Penny
    PS. did I do the code tags correctly this time?

  2. #2
    Registered User
    Join Date
    02-09-2005
    Posts
    63

    Equivalence or Alias of Custom Data Types ?

    Is it possible to have an "equivalence" (as in Fortran)(and I think C) for custom data structures?

    I want to be able to fill a data structure from cells on a sheet as a variant because I can do it in one line of code.
    Please Login or Register  to view this content.
    But I want to use/refer to it using the dot syntax of a "user defined" data structure instead of two sub-scripts, i.e. (2,3).

    Please Login or Register  to view this content.
    Can I do this? What is the syntax?

    **** Penny

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ****,

    You can create a User Defined Type structure in VBA. This will provide you with the Intellisense labels (dot syntax) when you type. You can construct a UDT that contains arrays, and mixed types. Here is an example using your case..
    Please Login or Register  to view this content.
    Here is how to use it. You have to declare a Variable in your Procedure as a "New ObjDimensions" type.
    Please Login or Register  to view this content.
    The scope (life time of the variable) lasts while the Sub is running.

    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 10-22-2007 at 02:35 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ****,

    I covered this in the answer to your last post...

    Equivalence or Alias of Custom Data Types

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    02-09-2005
    Posts
    63
    Leigh,

    1st, thanks for monitoring this forum & your recent answers.

    BUT, you missed my point completely - I guess I'm not good at explaining, will try again.

    I want to load a custom data structure with one statement similar to the way one does with a variant, e.g.
    x = range.value
    This creates a two dimensional structure in x for rows & columns respectively.

    Now I want to access x using dot notation, e.g.
    y = x(2).height

    Can this be done, if so, exactly how?

    ****

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The UDF loadCmdVariable might help you. I changed the properties of the data type, (END scares me as a variable name), but the idea is the same.
    Please Login or Register  to view this content.
    Last edited by mikerickson; 10-22-2007 at 09:09 PM.

  7. #7
    Registered User
    Join Date
    02-09-2005
    Posts
    63
    Mike - Exactly what I had in mind.

    THANKS

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1