Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create your own Property

VBA How To

Create your own Property

by  SteveBausch  Posted    (Edited  )
Create your own Property, it will show up in Intellisense, like any obedient property.

This can be done for any object with code, and since a worksheet is an object with code....

Just tested "Tagging" a code module, that works too, though I cannot say it's usefulness.

Normally, people think of adding properties to a class module, or to userforms to allow retrieval of "Canceled" or "Completed" booleans, etc. Keep in mind you shouldn't unload the form until you retrieve the property. Hide the form, that's okay, just don't unload it.


Have yet to see a decent tutorial that explained the "flow", so I have commented the code, and created descriptive namings.

Code:
Dim InternalVariable As String 'Internal variable that holds the property's value.

Property Let Tag(AssignedValue As String) 'Allows assignment
InternalVariable = AssignedValue 'Internal variable assigned as argument
End Property

Property Get Tag() As String 'Allows accessing
Tag = InternalVariable 'Property assigned value of internal variable
End Property

For Help on this topic, search on:
Property Let Statement
Property Get Statement
Property Set Statement




Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top