Searching Backwards in textarea

I have found a way to search forwards (or down) in a textarea but I’m having trouble searching backwards (or up).

Here is what I have for forwards (or down):

[code]Var searchText As String = tfFindUp.Value
Var charPos As Integer
Var startPosition as Integer

if taMain.SelectionLength > 0 then
startPosition = taMain.SelectionStart + 1
startPosition = 0

charPos = taMain.Value.IndexOf(startPosition, searchText)

If charPos >= 0 Then
taMain.SelectionStart = charPos
taMain.SelectionLength = searchText.Length
End If

Can anyone help me figure out how to search backwards?
By default Indexof only works moving forward. I was thinking of looping one character at a time backwards (-1) until it found the next. I also thought of reversing the text area in memory, but that was way too messy.

Any thoughts?

Invert the string first?

What are you really searching ?

From the end of the document back to the start, are-you searching the word Var or raV ?

search for all the found text selstart and sellength, and store them in an array
then you can go easily forward or backward in the array of the results.