how do i know my position inside a textbox?

for example, if i have a textbox with multiline, and alot of text inside. the cursor is somewhere in the middle.
how can i count - or get somehow the position of the cursor