Cache Properties for Repeated References

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.TextFor i = 1 To Ubound(arr)	arr(i) = tmp 	' Here use tmp instead of using Text1.Text repeatedlyNext I

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist