Determine if a TextArea is Scrolled to the Bottom

I can find the last line in a TextArea with code like

Dim lastLine As Integer = TextArea1.LineNumAtCharPos(TextArea1.Text.Len)

But I can’t successfully compare that against ScrollPosition because that value changes depending upon the height the window and the size of the elevator within the scrollbar.

Any ideas to determine if a TextArea has been scrolled to the bottom? I’m using this for a simple log window that auto scrolls unless you’ve scrolled up.

if TextArea1.charposxy(textarea1.width,textarea1.height)>=textarea1.text.len

off the top of my head… it has not be tested… you might need to tweak

I have a logWindow which does this:

  Sub Log(msg as string)
  textArea1.append msg + EndOfLine
  if checkboxAutoScroll.value = true then
    textArea1.ScrollPostion = 9999999
  end if

which works great, but requires the user to click the checkbox.

I wonder if one could do this:

    if (me.actualScrollPositon <  textArea1.ScrollPostion) then 
     ' user has manually scrolled - append message but don't scroll
      textArea1.append msg + EndOfLine
    else
     ' user has not scrolled, append text and scroll to bottom
      textArea1.append msg + EndOfLine
      textArea1.ScrollPostion = 9999999 
      me.actualScrollPositon =  textArea1.ScrollPostion
   end if

Edit-typos