How to delete the first 5 characters in odd lines of a memo? And show an example of how to do this with even ...

Closed due to the fact that the essence of the question is not clear to the party Nofate 18 May '15 at 9:33 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • five
    @ Nikola Krivosheya, According to the rules of the forum, questions should not be limited to solving or completing study assignments for students. Please clarify what you have done yourself and what did not work out. - karmadro4

2 answers 2

At least 3 options for checking for parity / oddness. The number a even when:

 (a mod 2)=0; odd(a)=false; (a and 1)=0; 

You can remove the first 5 characters from the str string as follows:

 delete(str, 1, 5); 

ps: and you can still go through one line and get only on even / odd ones.

     procedure TForm1.Button1Click(Sender: TObject); var i:integer; str:string; begin i:=0; while (i<=(Memo1.Lines.Count-1)) do begin str:=Memo1.Lines[i]; Delete(str, 1, 5); Memo1.Lines[i]:=str; i:=i+2; end; end; 

    Starting with i: = 0 - delete in odd ones, if you start with i: = 1, then we delete in even rows