自定义一个数组吧
const
  BoolToStr: array[Boolean] of String = ('错', '对');
...
begin
  ShowMessage(BoolToStr[1+1=2]);
end;

解决方案 »

  1.   

    自定义一个数组吧
    const
      BoolToStr: array[Boolean] of String = ('错', '对');
    ...
    begin
      ShowMessage(BoolToStr[1+1=2]);
    end;
      

  2.   

    自己定义:
    function booltostr(ib:boolean):string;
    begin
    if ib then result:=‘true’
    else result:=‘false’
    end;function strtobool(istr:string):boolean;
    begin
    if istr=true then result:=true
    else result:=false;
    end;
      

  3.   

    Delphi提供了这样的函数
    Function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
    例如:
      edit1.txt:=Booltostr(3<4);  //文本框中显示的是'0'
      edit1.txt:=Booltostr(true);  //文本框中显示的是'-1'
      edit1.txt:=Booltostr(false,true);  //文本框中显示的是'False'
      edit1.txt:=Booltostr(2=3-1,true);  //文本框中显示的是'True'
      

  4.   

    function BoolToStr(Bool: Boolean): string;
    begin
      if Bool then
        Result := 'True'
      else
        Result := 'False';
    end;