Consider these two examples of code that add a string to a textbox.
Text1.text = Text1.text & MyString Text1.SelStart = Len(Text1.text)
Text1.SelStart = Len(Text1.text) Text1.SelText = MyString
In the first example, you must copy the complete text from the textbox into a separate buffer to perform concatenation with the string MyString. You then need to copy the resulting string back to the textbox. This code requires allocating additional memory and performing two copy operations.
The code in the second example does not need an additional buffer. The concatenation of strings is executed inside the textbox buffer without transferring the text first outside the textbox and then back inside. This code is much faster and less memory-extensive. This second approach has an additional advantage of setting an insertion point directly at the end of the displayed text. In the first example, the insertion point is initially set to the beginning of the text, then transferred to the end, causing the control to flicker on the screen.