LineNumber:=SendMessage(Memo1.Handle,EM_LINEFROMCHAR,memo1.Selstart,0);
LineNumber is returned as a LongInt, but you can typecast it to an Integer.