Results 1 to 9 of 9

Thread: Display all the class name / objects

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    Question Display all the class name / objects

    Hola,

    I have this project where I created a lots of class and I need to process all the class/objects from this specific folder in my project named "Tables"

    Name:  tables.JPG
Views: 254
Size:  30.7 KB

    I already created the routine to get the real work done and I just doesn't want to type all the contents of the folder "Tables" to have them processed.

    Is there any way to read and process all the class under the folder "Tables"?

    Thanks in advance!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Display all the class name / objects

    Perhaps you could actually explain what "process" means. You generally don't "process" classes, but instances of classes, i.e. objects. Those objects can be created in many ways but it's generally not "reading" from a folder in a project. In short, provide a FULL and CLEAR explanation of the problem.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Display all the class name / objects

    When the program is running, that folder isn't really there, unless the program is looking back to the project that developed it and is manipulating the source code from which it is built. That seems pretty improbable, though.
    My usual boring signature: Nothing

  4. #4
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Display all the class name / objects

    You create your instance of your classes the same ways that if they weren't in a folder. VS doesn't care of the folder for the class so you just need :

    Code:
    dim att as new attendance
    dim bene as new benefits
    etc ....
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Display all the class name / objects

    Reflection is what you're looking for, but i don't know how you'd differentiate which folder your classes are in...

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Display all the class name / objects

    Quote Originally Posted by .paul. View Post
    Reflection is what you're looking for, but i don't know how you'd differentiate which folder your classes are in...
    If things have been done properly, those folders map to child namespaces. If things haven't done properly, there is no way to differentiate the folders because the folders don't exist as far as the types are concerned.

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    Re: Display all the class name / objects

    Quote Originally Posted by jmcilhinney View Post
    Perhaps you could actually explain what "process" means. You generally don't "process" classes, but instances of classes, i.e. objects. Those objects can be created in many ways but it's generally not "reading" from a folder in a project. In short, provide a FULL and CLEAR explanation of the problem.
    Process, I created a function that will process all those classes.

    Code:
    Call Extract(input table name, var1, var2, var3)
    I was thinking like using something like this but it seems not possible.

    Code:
    For each cls in folder Tables
         Call Extract(cls, var1, var2, var3) 
    Next cls

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    Re: Display all the class name / objects

    Thanks for all the replies and inputs. I will just create an instance of each class.

    Stay safe everyone.

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Display all the class name / objects

    Quote Originally Posted by hopia View Post
    Process, I created a function that will process all those classes.
    How is that an explanation of everything? If I ask you what X means I don't expect you to say "it means X". I meant what does the the function actually do. You know, an EXPLANATION.

    There is no folder at runtime. That folder is part of your project and the project doesn't exist, as far as the compiled EXE is concerned. Sure, you could write code that assumes that the EXE is located in the output folder under the project folder but that isn't going to be valid if you deploy the EXE somewhere. You could write code such that the user provides a folder path at run time and you then examine that folder, but that's not something special that you should need our help with. Beyond that, we can't really help you do what you want to do if you won't explain what it is you want to do.

Tags for this Thread

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