VBA Classes

Поделиться
HTML-код
  • Опубликовано: 22 июл 2024
  • In this video I explain about classes. Things that we cover is
    What are classes?
    Why do we need classes?
    What are properties, methods and events w.r.t classes
    and so many other things
    This video will be my building block for my next video which will explain about Object Oriented Programming in VBA so if you are not aware what classes are and how they work then I recommend watching this video.
    ----
    00:00 Intro
    04:54 Properties
    05:52 Get, Set and Let
    08:22 Creating an Object of a Class
    12:33 Methods
    29:16 Events
    39:26 Outro
    ----
    Practice Workbook Download: www.dropbox.com/s/24v25niaota...
    Software used for recording and editing this video
    Camtasia: techsmith.z6rjha.net/SidRecom...
    Disclaimer: The above is an affiliate link. At no additional cost to you, we will receive a small commission if you make a purchase using the above links. This helps support the channel. Thank you in advance for your support!
    Connect with me on social:
    LinkedIn: / siddharthrout
    Facebook: / sidzrout
    Instagram: / sidzthekidz
    Stackoverflow: stackoverflow.com/users/11405...
    Microsoft Excel VBA Facebook Group: / msexcelvba
    #ExcelVBA #ExcelMacro #VBAExcel #MSExcel #Excel

Комментарии • 26

  • @MyFakeBrand
    @MyFakeBrand Месяц назад

    Holy moly! I’ve been scripting with VBA for years but struggled with understanding classes. This is the video I needed. This new knowledge will help me right away in a project I am working on. Thank you!

    • @SiddharthRout
      @SiddharthRout  Месяц назад

      Thank you so much for your kind words! 🌟 I'm thrilled to hear that the video helped you understand VBA classes better. It's amazing to see how learning something new can immediately impact your projects. If you have any more questions or need further clarification as you dive into your current project, feel free to reach out. Keep up the fantastic work, and happy coding!

  • @MyPhotographic
    @MyPhotographic 2 месяца назад

    EXCELLENT Tutorial!!!!!!...... using real world example makes it so much easier to understand! - a couple of small requests/suggestions. Could you step through the code and explain as the program runs - it helps to understand the process flow. As you advance set breakpoints so there is not a lot of repetition. A second request/suggestion is to show how to crerate a user interface - perhaps as a follow up video? - A REALLY great job!!!...

    • @SiddharthRout
      @SiddharthRout  Месяц назад

      Thanks for the suggestions. Will try and incorporate them in my next video :)

  • @DanijelBlasko
    @DanijelBlasko 3 месяца назад +1

    Amazing job!

    • @SiddharthRout
      @SiddharthRout  Месяц назад

      Thanks for taking the time out to appreciate it. Strange, I did not get an alert for your comment.

  • @ramandeepsr
    @ramandeepsr Год назад

    Loved the way you explained. Thank you!! 😄
    Keep it up!

  • @JiriMerkl
    @JiriMerkl 6 месяцев назад +1

    Thanks for the explanation mr. Sidd. OOP is great if you want to be a good developer (i think). I've read a lot of concepts from internet, but there are misunderstanding data. This way is great. 🤗🤗

    • @SiddharthRout
      @SiddharthRout  6 месяцев назад

      Thanks Jiri for taking the time out to appreciate it 😊

  • @orange1826
    @orange1826 5 месяцев назад

    Great, clear, instructive video on classes using vba. Added it to my references of recommended sample code.

    • @SiddharthRout
      @SiddharthRout  5 месяцев назад

      Thanks for taking the time out to appreciate it.

  • @kevinmccurley7597
    @kevinmccurley7597 Год назад

    Excellent video Sid - very instructive!

    • @SiddharthRout
      @SiddharthRout  Год назад

      Glad you like it. And thank you for taking the time out to appreciate it. :)

  • @R72Investments
    @R72Investments 5 месяцев назад

    Hi Siddharth, this is my first time on your channel and I hit the subscribe button after only two minutes. Your easy to understand explanation at the beginning of the video has already convinced me. Well done! Keep up the good work!

    • @SiddharthRout
      @SiddharthRout  5 месяцев назад

      Thanks for taking the time out to appreciate it.

  • @user-iz7qp2we9f
    @user-iz7qp2we9f 8 месяцев назад

    Хоть и не на русском но я все равно понял основу принципа работы. Самый хороший обзор. Большое спасибо брат! Успехов твоему каналу. 🤝

    • @SiddharthRout
      @SiddharthRout  8 месяцев назад

      Рад помочь. Если у вас есть вопросы, вы можете задать их на русском языке, и я постараюсь вам ответить :)

  • @noviceprogrammer2011
    @noviceprogrammer2011 Год назад +1

    Why do you use composition?
    You could have declared a variable in the standard module, such as Dim MyVariable As Gear.
    Then in Sub DriveCar, you can replace .TheGear.GearUp with MyVariable.GearUp.
    Similarly for .TheGear.GearDown with MyVariable.GearDown.
    How does using TheCar.TheGear.GearUp help? I think it confuses people (certianly me)!
    Thanks

    • @SiddharthRout
      @SiddharthRout  Год назад +1

      Very good question! I used composition so that the relationship can be maintained. This way if the parent object is deleted, then the child object also loses its status. For example, if the car is destroyed then the Gear is also destroyed. If I keep it in a module separately then there is no relationship. Even when the car object is destroyed, the gear object will still be available. You don't want the gear to be dangling around after the car is destroyed. 😊

  • @KrazyMO
    @KrazyMO Год назад +1

    I created classes just so I can move multiple variables via a dictionary. Should I instead move the code that uses the variables into the class methods and just instantiate the class every time I need to manipulate data associated with the class?

    • @SiddharthRout
      @SiddharthRout  Год назад

      While I can't comment without looking at your code, it is a good idea in general to move variables inside classes and expose them via properties. This is in accordance with OOP concept and is called "encapsulation". It makes for better code overall.

  • @KuldeepSingh-nq1vi
    @KuldeepSingh-nq1vi Год назад

    I couldn't understand how event Works in class Module, you should have created this video in multiple parts in details by telling each and every concepts line by line.. 😂
    I want to learn WithEvent and Raise Event concept in details, so make a Video on these topics as well.

  • @noviceprogrammer2011
    @noviceprogrammer2011 Год назад +1

    The code in the downloaded workbook is different to the video.
    Sub MyCarExperience()
    CreateNewCar
    FillFuel
    DriveTheCar

    Dim CarTyreState As Double
    CarTyreState = TheCar.TheTyre.TyreCondition

    If CarTyreState < 40 Then
    MsgBox "Car Tyre Condition: " & CarTyreState & "." _
    & vbNewLine & "We will replace tyres now"
    Set TheCar.TheTyre = New Tyre

    MsgBox "Car tyres have been replaced."
    MsgBox "Car Tyre Condition: " & CarTyreState & "."
    End If

    Set TheCar = Nothing
    End Sub
    This line is wrong in the download:
    MsgBox "Car Tyre Condition: " & CarTyreState & "."
    but it's correct in the video.

    • @SiddharthRout
      @SiddharthRout  Год назад +1

      Thank you for bringing it to my notice. Will check and rectify it within 24 hours :)

    • @SiddharthRout
      @SiddharthRout  Год назад

      Fixed! Thanks again.