this was one of the most simple and clearly understandable explanations of classes in VBA ever. also thank you for adding music in the background. it helped drive the video along. thanks much for posting!
Just found this video and really enjoyed it. I have been trying to wrap my head around class modules for years and really helped to explain how they work and can be used! Thank you so much for creating/sharing this video!
@@BusinessProgrammer I subscribed to your channel so I will be sure to be notified when you post new videos. Really looking forward to watching all of your other videos as well.
Hola Sean, es perfecta tu explicación, sin dar tantas vueltas y queda muy claro como crear un módulo de clase. Me recuerda a lo similar que es "crear una tabla y sus campos" con sus parámetros en una base de datos como Mysql. De nuevo, muchas gracias, y aunque puedo escribir en inglés esta vez opté por lo mas fácil para mi. ;-) Saludos desde Argentina.
@@BusinessProgrammer Agreed. Music creates problems/distraction (specially when listening) or as long it it is in very low volume. But the concept was presented very nicely..... at least I understood when various other videos posted by others, I didn't understand clearly.
I'm glad you've decided to stop using music, as I find it very distracting when trying to concentrate on a complex topic like this. But other than that, an excellent presentation, looking forward to more of the same. Thanks.
Thanks for the well illustrated video on class module. Can you give a next video on how to make the object name dynamic so that the code lines need not be repeated for each object and handled within a loop. My class module has more than 100 properties and there are 8 objects of this class. Hence i do not want to repeat the lines for each object.
+Sean Johnson hello sir, how do you create a class module to trigger click event for activex spreadsheet (not user form) checkboxes... ole object checkbox1, checkbox2, checkbox3 etc so I don't have to write code for each individual checkbox?
This was great! So, as we go along creating these objects, how do we save them for later use? For example, a class named Users with properties like username, password, gender, age etc...
I believe that you can export the Class Modules... then import them into your next Project. Also, you can put the Class Module into your Personal Macro Workbook by dragging/dropping... then reverse that into your new Project.
Question: Suppose I have a class and it has a local variable called locVar. How would I call and use it in a method of that class? Can I just type(for instance) "locVar=..." or do I need to use dot (meaning, something like: class.locVar) ?
Hi Tal You need to declare the local variable as a module level variable within the class and then you can use it within all of your methods. So if you have a string local variable say Zip Code for example, then I would do something like this... Private mszZipCode as String ' (msz meaning module scope, string) mszZipCode can be used anywhere within your class but cannot be used outside it. Hope that helps...
can anybody help me out...i m doing a programme....i want a single click to work in multi sheets. but alltime i have to go in vb programme and run that in a connected proper sheet. i want to run that program when i will be in vb of sheet 1 and program output will be in sheet 3.I hope i tried my best to make u understand my problem.plz help me bro.
If you avoid to use "Feuil3.Select" anywhere in your program, it should work ... You can refer to cells in Feuil3 without selecting it. I am not sure if this what you are looking for.
HI Jay If you look at the image on the front of my video, you'll see clsCar at the top and rally car, Race Car and Police car beneath, rally, race and police car are instances. People use a cookie cutter as a metaphor for classes, the cookie-cutter being the class and the cookie being the instance of the class, you can't eat the cookie cutter but you can eat the cookie. Similarly, you can't use the class directly but you can use the objects created from the class, the objects are the instances. With a standard module you just run the code, but with a class module you have to create an instance of it with dim instance as clsModuleName set instance = new clsModuleName instance.Drive instance.NumberOfWheels = 4 Hope this helps
@@BusinessProgrammer Hey sorry to disturb you again we use Dim Instance as ClassModule Set Instance = New ClassModule is this method applied only when we define a class? Because I have seen people using this method for the class modules which are already defined by excel Thanks
This method is used to create an instance of an object, Excel and other Microsoft vba programs also have built in classes so you instantiate them in the same way as class modules. For example the collection class is built into vba therefore... dim objC as collection set objC = New Collection objC.add "Some Item" Hope that helps
Thanks, but the music made it impossible to concentrate and it overpowered your voice. I've never understood why people add music to these kinds of instructional videos. If the viewers want music, they can play it on their own devices.
this was one of the most simple and clearly understandable explanations of classes in VBA ever. also thank you for adding music in the background. it helped drive the video along. thanks much for posting!
Ich küss doch dein herz für dieses video
Ich bin froh, dass du dieses Video hilfreich fandest
Man, this sound track is awesome, Gr8 job!
Just found this video and really enjoyed it.
I have been trying to wrap my head around class modules for years and really helped to explain how they work and can be used!
Thank you so much for creating/sharing this video!
Glad You found it helpful Eric, given its five years old, I think it's going to be time soon for me to do a remake of this video.
@@BusinessProgrammer I subscribed to your channel so I will be sure to be notified when you post new videos. Really looking forward to watching all of your other videos as well.
Wow, wish I had watched this video before: I could have done so many things more efficiently if I knew OOP in VBA. Thanks a lot for the great video!!
You're welcome, sorry for the later reply
you are a monster dude, thank you. no long drawn out convoluted explanation
Glad you found it helpful, I remember "back in the day" trying to find out the purpose of class modules, and not being able to get a straight answer.
@@BusinessProgrammer definitely and vba has given me the confidence i needed to do other coding languages, truly amazing stuff
The music totally brings it to a Chad level.
Do . you mean chav?
Thank you! I finally understand how to create and use a class module in VBA, great video!
Glad I could help!
"The magic of objects!!" Nice!
Yep, they are the secret!
hahaha
Sean Johnson how can i Learn the vba code in powerpoint?
Great video to learn at first time about class module. Hugely helpful Sir.
Glad I could help Ashokan
This is fantastic and super clear. Thank you, Sean!
Thanks for the feedback Ryan, sorry for the the "slight" delay in getting back to you.
Without that noise in the background a great video. I had to switch the sound off as otherwise I could not focus on the content.
Yes, I don't add music to my videos any more, can't change this one though
@@BusinessProgrammer But thank you for your prompt response! Great ...
Hola Sean, es perfecta tu explicación, sin dar tantas vueltas y queda muy claro como crear un módulo de clase.
Me recuerda a lo similar que es "crear una tabla y sus campos" con sus parámetros en una base de datos como Mysql.
De nuevo, muchas gracias, y aunque puedo escribir en inglés esta vez opté por lo mas fácil para mi. ;-)
Saludos desde Argentina.
Hola alfredo
De nada, me alegro de que te haya gustado.
tienes razón, es como tablas y campos.
Si mi español es malo, culpa al traductor de Google ;-)
awsome !
Thanks from Montréal (Quebec)
mon plaisir :-)
Excellent explanation, I finally understood :)
100/100
Great!, So why only 25 out of 5000 ?
:-)
@@BusinessProgrammer Google translate haha, fixed it to 100/100 :)
Much Better ...
:-)
simple and clear example
Glad you found it helpful
You don't need the music, it masks your soft voice. The technical content is good.
I know, I've stopped using music, i'm afraid it's encoded into this tutorial.
@@BusinessProgrammer Agreed. Music creates problems/distraction (specially when listening) or as long it it is in very low volume. But the concept was presented very nicely..... at least I understood when various other videos posted by others, I didn't understand clearly.
I'm glad you've decided to stop using music, as I find it very distracting when trying to concentrate on a complex topic like this. But other than that, an excellent presentation, looking forward to more of the same. Thanks.
thanks sean! cool accent - i havent done vba in a while and thought maybe i should have a more OOP approach this time - this helped. Subbed.
This is great! Thank you so much!
Thanks for the well illustrated video on class module. Can you give a next video on how to make the object name dynamic so that the code lines need not be repeated for each object and handled within a loop.
My class module has more than 100 properties and there are 8 objects of this class. Hence i do not want to repeat the lines for each object.
superb mr john
Thanks Vijay
Easier than reading the microsoft page!!!
I agree the tech spec pages can be cryptic or unnecessarily complicated
Very intense at 1.5x speed. Music makes it seem like we're disarming a bomb in an action movie.
Learning and being entertained, what a bargain!
Very usefull! Thank You sir.
Your welcome
Thank you, Sir.
Very Good! its hard to find good material
Hi Rodrigo, Glad you liked it.
+Sean Johnson hello sir, how do you create a class module to trigger click event for activex spreadsheet (not user form) checkboxes... ole object checkbox1, checkbox2, checkbox3 etc so I don't have to write code for each individual checkbox?
I don't have a sister, wasn't able to try this code. Just joking... Thank you for the video!
Very good
cool, Thumbs up.
Fine Sir!!
This was great! So, as we go along creating these objects, how do we save them for later use?
For example, a class named Users with properties like username, password, gender, age etc...
I believe that you can export the Class Modules... then import them into your next Project.
Also, you can put the Class Module into your Personal Macro Workbook by dragging/dropping... then reverse that into your new Project.
My bien no te entiendo pero te veo, gracis
Great tutorial. Very annoying background music. Is very distracting I wish you did not add background music
I wish I had left the background music out also, probably need to create another video on this topic.
Is this your music Sean?
It's comes with camtasia studio - screenrecorder/ video editor.
I've stopped using music in my videos as most people find it distracting.
lil wayne guitar solo in the background music
I don't know what you mean, it's canned music licensed by Techsmith - camtasia studio.
Question:
Suppose I have a class and it has a local variable called locVar. How would I call and use it in a method of that class? Can I just type(for instance) "locVar=..." or do I need to use dot (meaning, something like: class.locVar) ?
Hi Tal
You need to declare the local variable as a module level variable within the class and then you can use it within all of your methods. So if you have a string local variable say Zip Code for example, then I would do something like this...
Private mszZipCode as String ' (msz meaning module scope, string)
mszZipCode can be used anywhere within your class but cannot be used outside it.
Hope that helps...
Yes, that helped very much:)
Thank you!
can anybody help me out...i m doing a programme....i want a single click to work in multi sheets. but alltime i have to go in vb programme and run that in a connected proper sheet. i want to run that program when i will be in vb of sheet 1 and program output will be in sheet 3.I hope i tried my best to make u understand my problem.plz help me bro.
If you avoid to use "Feuil3.Select" anywhere in your program, it should work ... You can refer to cells in Feuil3 without selecting it. I am not sure if this what you are looking for.
Video was what I wanted but the music was too loud and not needed. Quite annoying
Can someone explain in simple words what is an instance please......
HI Jay
If you look at the image on the front of my video, you'll see clsCar at the top and rally car, Race Car and Police car beneath, rally, race and police car are instances.
People use a cookie cutter as a metaphor for classes, the cookie-cutter being the class and the cookie being the instance of the class, you can't eat the cookie cutter but you can eat the cookie. Similarly, you can't use the class directly but you can use the objects created from the class, the objects are the instances.
With a standard module you just run the code, but with a class module you have to create an instance of it with
dim instance as clsModuleName
set instance = new clsModuleName
instance.Drive
instance.NumberOfWheels = 4
Hope this helps
@@BusinessProgrammer omg thanks you replied
Oh that was great explanation
Thanks for sharing your precious knowledge and time 😊
@@BusinessProgrammer Hey sorry to disturb you again
we use
Dim Instance as ClassModule
Set Instance = New ClassModule
is this method applied only when we define a class?
Because I have seen people using this method for the class modules which are already defined by excel
Thanks
This method is used to create an instance of an object, Excel and other Microsoft vba programs also have built in classes so you instantiate them in the same way as class modules.
For example the collection class is built into vba therefore...
dim objC as collection
set objC = New Collection
objC.add "Some Item"
Hope that helps
@@BusinessProgrammer oh okay got it thank you 😊
Thanks, but the music made it impossible to concentrate and it overpowered your voice. I've never understood why people add music to these kinds of instructional videos. If the viewers want music, they can play it on their own devices.
I stopped adding music a long time ago, problem is I can't remove it from the older videos
Music is annoying
I really would have like so see your video but the annoying and distracting music made me leave....
Yes, I know, I need to remake the video