Results 1 to 10 of 30

Thread: Class Stuff: VBA Custom Classes & Objects, Class Modules

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,454
    Rep Power
    10

    Class Stuff: VBA Custom Classes & Objects, Class Modules

    Administrative Notes: : this blog is not finished - this blog on class stuff to be finished next winter hopefully. April 2020 or later... pics in eileenslounge Nick basics



    Class Stuff



    Introduction To Classes
    Class Stuff: VBA Custom Classes & Objects, Class Modules ( Custom Events)
    .

    Class Modules.
    This is a bad start point. But it seems to be often peoples first experience with this “Class stuff”. Class modules are a small way down from the start of what it is all about, and for the sake of .. I don’t know what .. the subject is often started with the mechanics of setting up a class module. I think using this typical approach and start point seems to detract from someone getting the point.( Its as bit like explaining to someone in detail how to change a wheel on a car when he needs to know how to organize running a taxi company )
    I think this results in that somebody trying to learn will .. not see the wood for the trees.
    It is true that a class is created by inserting a Class Module (in your VBA project) to which you give a name, but that is just arbitrarily how the mechanics of it have been written.
    So I won’t start the story there, by the inserting of a Class Module.

    It is a better start point to say…” In VBA you can create your own custom objects by defining classes. Classes act as templates for new objects “

    A brief introduction to objects and class objects in VBA. Object Orientated Programming,
    If you understand a bit about Object Orientated Programming, OOP, then you will know that it is all about Objects, and an object can be a whole lot of diverse things. OOP is an annoyingly vague concept. The Objects tend to be organised hierarchically starting with the big ones at the top of the hierarchy, and going down through smaller ones.
    http://www.excelfox.com/forum/showth...ange#post10809 , , https://imgur.com/tirYIdz http://i.imgur.com/tirYIdz.jpg
    Something running parallel to this hierarchical structure which loosely fits into it all, is that we define a Class as a blueprint or Template from which to build one or more objects of that type , or model, or Class. Class is also a vague concept and means like a template, blueprint , or set of instructions or procedures to define how objects built from the Class will look like.
    At this point in the discussions, the VB Editor starts getting very misleading: it does not represent clearly the actual structure that we have for two reasons:
    _ the positioning of thing is not consistent
    _ some things are simply not shown, ( possibly deliberately as we have no access to them. )

    Example Model of a workbook
    The Workbook

    __________________________________________ThisWorkbook
    Lets restrict ourselves for the sake of simplicity to having a single workbook as the “start” . Then we could consider a workbook class from which our single workbook is made
    ThisWorkbookClassObject___ThisWorkbookObject.
    What we see in the VB Editor left hand side explorer window is somehow a representation of the actual Excel object, ( or “instance” of it ) , that we have in front of us. The imprecise definition of objects allows us to consider the code module ( which appears when you double click on ThisWorkbook in the left hand VB Editor explorer window ) as part of workbook object.


    In the next post we review the existing Class objects, which inspection of the left hand side explorer window of the VB Editor appears to indicate that we have some access to.
    We will see that they are somewhere in between a normal macro code module and a Class module. They could possibly be described as object modules, or Class object modules

    Having considered those two existing class related things, we will go on to discuss the other two class related things, which we will see are more close to a "pure" class thing. Those will be the things related to the classic "Class module" and the UserForm








    https://web.archive.org/web/20180518...l/classes.aspx

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=320960#p320960
    https://eileenslounge.com/viewtopic.php?p=320957#p3209573
    https://eileenslounge.com/viewtopic.php?p=318868#p318868
    https://eileenslounge.com/viewtopic.php?p=318311#p318311
    https://eileenslounge.com/viewtopic.php?p=318302#p318302
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317857#p317857
    https://eileenslounge.com/viewtopic.php?p=317541#p317541
    https://eileenslounge.com/viewtopic.php?p=317520#p317520
    https://eileenslounge.com/viewtopic.php?p=317510#p317510
    https://eileenslounge.com/viewtopic.php?p=317547#p317547
    https://eileenslounge.com/viewtopic.php?p=317573#p317573
    https://eileenslounge.com/viewtopic.php?p=317574#p317574
    https://eileenslounge.com/viewtopic.php?p=317582#p317582
    https://eileenslounge.com/viewtopic.php?p=317583#p317583
    https://eileenslounge.com/viewtopic.php?p=317605#p317605
    https://eileenslounge.com/viewtopic.php?p=316935#p316935
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317014#p317014
    https://eileenslounge.com/viewtopic.php?p=316940#p316940
    https://eileenslounge.com/viewtopic.php?p=316927#p316927
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 10-04-2024 at 10:21 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

Similar Threads

  1. PQ - IP C class generator
    By sandy666 in forum ETL PQ Tips and Tricks
    Replies: 0
    Last Post: 10-22-2020, 05:16 AM
  2. Backup all modules, class modules and userforms to a selectable folder
    By MrBlackd in forum Excel and VBA Tips and Tricks
    Replies: 1
    Last Post: 04-06-2014, 08:33 AM
  3. Manipulate VBA Array Object Using Class Module
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 0
    Last Post: 06-06-2013, 07:53 PM
  4. Array Class Module
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 3
    Last Post: 12-20-2012, 11:22 AM
  5. Class Objects Created Using the CreateObject Method That Employs Late Binding
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 08-16-2011, 12:38 PM

Posting Permissions

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