+ Reply to Thread
Results 1 to 7 of 7

User-Defined Data Types

  1. #1
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    User-Defined Data Types

    Hello,
    My question is about creating User-Defined Data Types. Is there ANY way possible i can create a User-Defined Data Type that declares a variable of another User-Defined Data Type instead of the Pre-Defined User Types like String, Integer, etc?

    The following explains my problem in more detail.

    I know to create a User-Defined Data Type at the top of the module before any procedures. Like this:

    Please Login or Register  to view this content.
    In a procedure I would then declare a variable as that type using a Dim statement. Like this:

    Please Login or Register  to view this content.
    So, in the first code example above I created a User-Defined Data Type called CustomerInfo. And in that User-Defined Data Type I declared the variable Company and RegionCode as a String and Integer, respectively. String and Integer being, of course, Pre-Defined Data Types.

    Then in the next code example I declared the variable in a procedure.

    All that works just great.

    BUT... Is there any possible way to create a User-Defined Data Type with a variable that is declared not as a Pre-Defined Data Type, like String and Integer, but instead is declared as another User-Defined Data Type?

    It's my understanding an example would look like this:

    Please Login or Register  to view this content.
    The above would come at the top of the module, before the procedures. The only problem with this is that I didn't declare the variable EveryCompany using a Dim statement. That's something you have to do when using a User-Defined Data Type but not when using a Pre-Defined Data Type. However, the VBE won't allow me to use a Dim statement before the first procedure.

    So, in light of this, is there ANY way possible i can create a User-Defined Data Type that declares a variable of User-Defined Data Type instead of the Pre-Defined User Types like String, Integer, etc.

    Is there any workaround? I really want to create a hierarchy of Data Types...

    Thanks for your help in advance!!! I really appreciate the guidance!
    Last edited by CrazyFileMaker; 04-13-2009 at 02:48 AM. Reason: Forgot the Code Tags!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User-Defined Data Types

    Yes, you can.

    Please edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: User-Defined Data Types

    Great!!

    Could you or someone elaborate as to how?

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: User-Defined Data Types

    Crazy, as my colleague requested earlier, please modify your original thread to enclose any code within CODE tags. In the post editor, you can press the # button on screen to generate code tags, and then place your code between those tags.

    You will not get responses from others until you've complied with the request of a moderator (that's part of the forum rules as well).

  5. #5
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Talking Re: User-Defined Data Types

    Oops... Sorry shg! And thanks for pointing that out pjoaquin. At first I misunderstood and actually tagged the post with the word "code"!

  6. #6
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: User-Defined Data Types

    Hi

    I am afraid I don't really understand what problem you are having - your code should compile without a problem (so please explain exactly what steps you are taking which is causing you problems). The following which is similar also works without issue:

    Please Login or Register  to view this content.
    Richard
    Richard Schollar
    Microsoft MVP - Excel

  7. #7
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: User-Defined Data Types

    Richard,

    I see now I was actually making a mistake in the procedure. Your example cleared things up for me. Thanks to you, I'm making some great strides now. I appreciate the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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