Show Cursor when TextArea gets focus

I’m moving a long string of text into a TextArea and I have a certain SelStart point which can be anywhere in the text. How do I get the TextArea to open with the cursor showing even though it might be in the middle of the long string. If it is not at the beginning or the end, I have to scrool and look for it.

There is no simple way to do what you want with precision.

One thing you can do is use ScrollPosition to very grossly position the TextArea where SelStart is :

TextArea1.SelStart = Instr(TextArea1.Text, "eggs")-1 TextArea1.ScrollPosition = TextArea1.SelStart/45

This necessarily approximate, since lines are not uniformly 45 characters (I counted 50 on the longest visible) because of the wrapping. But that should ensure that the cursor will be visible.

Look into LineNumAtCharPos

[code]dim start As integer = TextArea1.SelStart

dim line As integer = TextArea1.LineNumAtCharPos(start)

TextArea1.ScrollPosition = line[/code]

[quote]dim start As integer = TextArea1.SelStart

dim line As integer = TextArea1.LineNumAtCharPos(start)

TextArea1.ScrollPosition = line[/quote]

Works great, thanks!