This line triggers the TextChanged event before you finish executing the code in the TextChanged event. textarea,text=processTheText(textarea.text)
Because you’ve replaced the text, the cursor position is at the end when it starts this all over again.
Create a variable in the TestArea window called isChanging, and set it to false
in the text changed event, add the code:
If isChanging Then
Return // prevents exectution of TextChanged event while code is changing the text.
End If
isChanging = True
curPosition = me.SelectionStart
me.Text = processTheText(me.Text)
me.SelectionStart = curPosition
isChanging = false
Works perfectly! Thank you very much - I have been working on the cursor problem for days while reading umpteen forum responses regarding textarea cursor issues. I am very glad you read my entry and I thank you for your time and response. Maybe the hair I’ve pulled out will grow back … .