如果只是检查字符串是否是整型数据,可以用StrToInt。

解决方案 »

  1.   

    // s: string
    for i := 1 to Length(i) do begin
       // 访问 s[i] 即可
    end;
      

  2.   

    不是这么简单的,还有其它的用途如遇到+号就退出
    不是在onkeypress里编
      

  3.   

    type userarray=array of string;    function tform1.split(s:string;dot:char):userarray;
        var
         str:userarray;
         i,j:integer;
        begin
           i:=1;
           j:=0;
           SetLength(str, 255);
           while Pos(dot, s) > 0 do
           begin
            str[j]:=copy(s,i,pos(dot,s)-i);
            i:=pos(dot,s)+1;
            s[i-1] := chr(ord(dot)+1);
            j:=j+1;
           end;
           str[j]:=copy(s,i,strlen(pchar(s))-i+1);
          result:=str;
        end;你可以改造一下,让它来达到你需要的结果。
      

  4.   

    完全同意stoneg(石头)的,string本来就是“字符串”,就是一串字符
    // s: string
    for i := 1 to Length(i) do begin
    //中间判断各种情况,产生不同处理
    end; 
    这种方法更科学
      

  5.   

    for i := 1 to Length(s) do
      if not s[i] in ['0'..'9', '-'] then break;
    result := i = Length(s);
      

  6.   

    以上代码中for 中使用的i在Result = ...会出问题,该为:i := 1;
    while (i < length(s)) and (s[i] in ['0'..'9', '-']) do
      inc(i)
    result := i = Length(s);
      

  7.   

    更正: (i <= Length(s))
      

  8.   

    采用循环和字符操作函数来取字符串中字符,采用strtoint来设置成整数。