Insert text in a TextArea

I wasted 40 minutes to seach how to Insert text in a TextArea, and I only found how to Append text…

Then I gave up…

I start to undestand why newbies ask so simple questions…

How do I Insert Text in a TextArea ?

usually, something like

selStart = position
selLength = 0
selText = NewText

although that is Api 1 and this got renamed properly.

Thank you Tim, but this is to Append text and I already use it instead of ‘+’ to Append text.

But I want to Insert Text (at different position like 0 or at a computed position).

Christian (I read your answer while writing this to Tim):
Thank you for reminding me the API 1 code (I confess that I forgot this while I was searching without any internet access yesterday).

Any taker for API2 code ?

Yes, I need coffee, sorry.

SelectionStart with SelectionLength = 0

Then perhaps AddText ?

No, AddText definitively is Append (it always place the text at the end of the actual text…).

Coffee ? Its cold today, and I need one too (but a hot coffee !) :wink:

Usually, I found answers (to newbies simple questions) either in the documentation or experimenting… but this time I’m short of answer.

Humph. Well unless someone has a clever answer I can only propose a clumsy brute force method: copy the text from the text area into two strings, then reassemble it along with the extra text. But that seems unsatisfactory.

Have you looked at styled text?

No, last time I looked at StyledText… it was bugged (long time ago)… And in this case, I do not need styles at all.

And the brute force: I do not even think at that since Insert Text is like Append Text: a basic feature…

Maybe in some hours, when America will wake up, we will get the answer…

Christian gaves me the idea to search differently:


This is a brand new project, so I took an empty one, created with Xojo 2015r.

This allows me to get the above help (API1 → API2).

I cannot use that 2015 version on my M1 and my i5 have a broken monitor (nd the keyboard have troubles): not easy to use at home (with an external Monitor)…

With Xojo 2022r3:

I only need to set the Default Font and Style to avoid getting the Style andb Text of the first character…

After another coffee, I realised that I will have to set some colors (and maybe some styles too, I do not know yet; I only started the project yesterday for less than one hour and 40 minutes were wasted for a search…).