function getrelativeselstart lparameter nSelstart && this is editbox.selstart property nLines=memlines(memofield) nLength=0 For n=1 to nLines if nLength+len(mline(memofield,n))+2>nSelstart return nSelstart-nLength endif nLength=nLength+len(mline(memofield,n))+2 && allow 2 for chr(13)+chr(10) EndforThis is the idea. I did not test this code so check it carefully when implementing.