Insert/Overwrite Text in Text Area

Hey all, I’ve got a situation where I need some advice.

I need to be able to programmatically insert text at a specific point in a text area. And I want the text I input to have the option to overwrite in the text area.

I can select the insertion point by doing a me.SelStart = X but then doing anything like me.appendtext ends up appending the text not putting it at the insertion point. If I type, the typed characters are inserted at the insertion point. Is there a way to do it programmatically?

I know I can take and move what is to the right of the insertion point to another variable and do my operations in that variable and then append it back to the text area when done.

Is that the best way to do this? I don’t want to re-invent the wheel if there’s some other method that I am just not seeing or missing.

Thanks,

Jon

if you have the start point set with me.SelStart = X
use Seltext

me.Seltext = // your text

[quote=133301:@Axel Schneider]if you have the start point set with me.SelStart = X
use Seltext

me.Seltext = // your text

See, I KNEW I was missing something! Perfect. And I can do the overwrite easily too…

So If I have data in a string variable s, I can do:

Dim s as string = "This is a test."

me.SelStart = X
me.SelLength = s.len

me.SelText = s

That’s EXACTLY what I needed! Thanks! :slight_smile:

Function KeyDown(Key As String) As Boolean dim ovw as boolean = true // Overwrite when true dim offst as integer = me.Selstart if me.SelLength = 0 then me.Sellength = 1 end if End Function