Hello! I wrote a program that converts the entered string, removing all letters from it.

procedure TForm1.Button1Click(Sender: TObject); var txt, Sum: string; i, num: Integer; begin memo1.Lines.Clear; txt:=Edit1.Text; for i:= 1 to Length(txt) do begin if TryStrToInt(txt[i], num) then begin Sum:=sum+IntToStr(num); end; end; Memo1.Lines.Add(sum); end; end. 

What do I need to replace IntToStr in order not to IntToStr letters, but numbers? Where can I see a complete list of such operators?

    3 answers 3

    Or replace your check with:

     if txt[i] not in ['0'..'9'] then begin Sum:=sum+txt[i]; end; 

      It is enough to change the condition in this code like this:

        if Not TryStrToInt (txt [i], num) then
            Sum: = sum + txt [i];
      

      PS Begin ... End on the condition can be omitted, and on the cycle too.

        Here's a link to you where quite a few functions are described.