我想把str型转成int型用什么语句呀?

解决方案 »

  1.   

    onverts a string that represents an integer (decimal or hex notation) to a number.UnitSysUtilsCategorytype conversion routinesDelphi syntax:function StrToInt(const S: string): Integer;
    DescriptionStrToInt converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number. If S does not represent a valid number, StrToInt raises an EConvertError exception.This example uses two edit boxes and a button on a form. When the user clicks the button, the code converts the values in the edit boxes to numbers, adds them, and displays a message indicating the sum:procedure TForm1.Button1Click(Sender: TObject);var
      I: Integer;
      J: Integer;
    begin
      I := StrToInt(Edit1.Text);
      J := StrToInt(Edit2.Text);
      ShowMessage(IntToStr(I + J));
    end;
      

  2.   

    var 
    a:string;
    b:integer;
    begin
    a:='12354';
    b:= StrToInt(b);
      

  3.   

    strtoint(edit1.text)   //在括号里是字符类型。
    strtofloat(edit1.text)   //str 转换成 real 类型;
      

  4.   

    try
    strtoint('字符串');
    except
    showmessage('不是整数');
    end;
    请关注:
    http://expert.csdn.net/Expert/topic/1733/1733460.xml?temp=.5655023
    http://expert.csdn.net/Expert/topic/1733/1733461.xml?temp=.5569574
    http://expert.csdn.net/Expert/topic/1733/1733463.xml?temp=.2091638
    http://expert.csdn.net/Expert/topic/1733/1733464.xml?temp=.5237543
    半小时结贴
      

  5.   

    var 
    a:string;
    b:integer;
    begin
    b:= StrToInt(a);
      

  6.   

    function StrToInt(const S: string): Integer;
    var
      E: Integer;
    begin
      Val(S, Result, E);
      if E <> 0 then ConvertErrorFmt(@SInvalidInteger, [S]);
    end;
      

  7.   

    哈哈,搂主,结贴吧,20分你看这么多人,已经是僧多粥少了,再来几个人说StrToInt,连分都不够了,:)