Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Apr 7, 2000



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

Cache Properties for Repeated References

If you have to reference a control's property repeatedly, it's better to assign the property to a temporary variable, then use that variable. This technique is called property caching. For example, if you need to assign text value in the Text1 textbox to all elements in an array named arr, it's better to assign the value to a temporary variable and use it for the assignment in the loop:
tmp = Text1.Text
For i = 1 To Ubound(arr)
	arr(i) = tmp 
	' Here use tmp instead of using Text1.Text repeatedly
Next I
Jai Bardhan
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