How to INSERT (not replace) some text into a TEXT control

T

ThomasAJ

I want the user to position the caret inside the control (somewhere among
existing characters in that control) and then click a button to insert the
contents of a variable containing text. Of course as soon as he clicks the
button the code will not know where to insert.
 
S

Sergey Poberezovskiy

You can declare a module level variable, say
Private myTextSelStart As Integer
And set it when leaving the TextBox

Private Sub Text0_Exit(Cancel As Integer)
myTextSelStart = Text0.SelStart
End Sub

Then you can use this variable inside the Button click

HTH
 
S

Sergey Poberezovskiy

myTextSelStart will hold the selection start position or 0 if never changed
 
Top