devxlogo

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

devx-admin

Share the Post: