Library tutorials & articles
Introduction to Class Programming
Property Get/Let
Every time you assign a new value to a property, Visual Basic checks whether there's an associated Property Let procedure and passes the new value to its associated Private variable. If the code can't validate this new value, it raises an error and throws the execution back to the caller. Otherwise, the execution proceeds by assigning the value to the Private variable. And when the caller code requests the value of the property, Visual Basic executes the corresponding Property Get procedure, which simply returns the value of the Private variable. Try to trace your code by pressing F8, and see what actually those property procedure do.
NOTE
The type expected by the Property Let procedure must match the type of the value returned by the Property Get procedure.
You might be asking this question, "Why not just use a public variable to store property values? In a sense, we are just using a sort of indirection. Why not use function to return a value or sub to assign a value" In some cases that may work fine; however, if you want to make sure that the value assigned to the property is valid, you have to write validation code when the value is assigned. And usually you this by creating a Sub or Function to validate the public variable or worst you end up coding a lot in the client (form) for this validation routine. It end up, we did not benefit for the characteristic of OOP which is encapsulation, stated that "an object is the sole owner of its own data." And this is the benefit of using a property procedure.
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Wouw, thanks for this great explanation on how to use and make classes. I always coded in VB with function in normal Modules, now i'm going one step further... Trying it out...
!--removed tag-->Great Tutorial !! Helped me a lot
!--removed tag-->[quote user="Developer Fusion Bot"]
This thread is for discussions of Introduction to Class Programming.
[/quote]
This was the best explanation to "class", I have ever come across. Hats off to you.
Hello Sir,
I have just seen u'r examples for class module.u'r explaination is simply superb!!!!
now i clearly understood the class module concept in VB.
Thanks
Bhavani Josyula
It s a great sample about the class programming. However, it s still uncertain for me where I can use this in real life.
Can anyone give me an example ?
what kind of help you wants from me. i mean to clear out your visual basic basics by giving you some tutorials or anything else. bye
I would appericiate if u can show me the way to learn this programe.
TQ
I have worn Google to a frazzle looking for help. most of which was comprised of a few samples.
You have helped "elucidate" me with both the why and how-to and that is no small task.
Thanks so much for your efforts and help.
What a tutorial !! man i like it. this tutorial shows me another side of visual basic wow!!
This is really a good tutorial on Visual Basic. I was really coinfused between let, get properties. But this is the final place which solved ll my problems
vbexplorer.com has also an excellent oop tutorial, if youre looking for some more,
and I have found a german article at vbarchiv.de that seems very good (i can
tell because I studied german when in grad. school, swe).
Maybe I should try an translate it to english...
This thread is for discussions of Introduction to Class Programming.