Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Create Custom Properties For Forms or Class Modules

Have you ever wanted to push a variable onto a form without using a tag? Property functions let you create custom properties for forms or class models. Use PropertySet, PropertyGet, and PropertyLet statements to manipulate custom properties. For example, you want to send a key value to a form so that the key is there in time for an SQL query to use it in a condition. Include a variable declaration for the property as a form-level variable:
 Private msKey as String
Then add two procedures for PropertySet and PropertyLet for the form:
 Public Property Let GetKey(vNewValue)
	msKey = vNewValue
End Property
Public Property Get GetKey()
	GetKey = msKey
End Property
You can now set the property from elsewhere by using:
 Form1.GetKey = "David"
In your form, use the variable you declared for any usage in your code. Property Procedures can be a bit more complex. But, the point is that the VB4 has become much more adaptable to your needs. Customize it to fit.
Crescent Tech
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date