如何判断edit.text值的类型是字符型还是数字型
if edit1.text='' or [] then
begin
showmessage('Error');
end;

解决方案 »

  1.   

    try
      strtofloat(edit1.text)
    except
      showmessage('Error');
    end;
      

  2.   

    try
      strtoInt(edit1.text)
    except
      Exit;
    end;
      

  3.   

    如果不想用异常
    strtointDef
    strtofloatDef
      

  4.   


       for j:= 1 to Length(xfpjl) do
         begin
          if (xfpjl[j] = '1') or (xfpjl[j] = '2') or (xfpjl[j] = '3') or
             (xfpjl[j] = '4') or (xfpjl[j] = '5') or (xfpjl[j] = '6') or
             (xfpjl[j] = '7') or (xfpjl[j] = '8') or (xfpjl[j] = '9') or
             (xfpjl[j] = '0') then
          MyString:= MyString+ xfpjl[j];
         end;
    试试这个   建议你 保存   很有用的
      

  5.   

    楼上的什么垃圾东东阿。我保存的:
    判断数值//可以判断s字符串是否为数值,负数像-1也可以判断
    function IsNumeric(S:string):Boolean;
    var
    i:integer;
    begin
     Result :=True;
     for i:=1 to Length(s) do
     begin
      if (s[i] in ['0'..'9','.','+','-']) then
      begin
       if i>1 then
       if (s[i]='+') or (s[i]='-') then Result :=False;
       end
       else Result :=false;
     end; //for
     if CharInStr('.',s)>1 then Result :=False;
    end;
      

  6.   

    用函数trystrtoInt不过要有Delphi6
      

  7.   

    funcation(s:string;):boolean;
    var
      i,j:integer;
    begin
         j:=0;
         for i:=1 to length(s) do
            begin
                if not (s[i] in ['0','1','2','3','4','5','6','7','8','9','0','.')    then begin   result:=false; exit;end;
                if s[i]=' ' then inc(j);
                if j>1 then begin result:=false;exit;end;
           end;
         result:=true;
    end;
    比笨的办法,传入的s,要trim(s);
      

  8.   

    procedure MyProc();
    var
      s: sting;  
      i,nLen: integer;
    begin  
      if edit.text = '' then exit;
      s := edit.text;
      nLen := Length(s);
      for i := 1 to nLen do
      begin
        if not (s[i] in ['0'..'9']) then 
          ShowMessage('not Num!');
        //if not (s[i] in ['a'..'z','A'..'Z']) then
          //ShowMessage('not Character!');
      end;
    end;我想你最好学个函数来判断比较好。仅提供思路。
      

  9.   

    function isnumeric(value:string):boolean;
    var
      d:double;//判断是浮点数,如果判断只能为整数,可以改为 d:integer;
      code:integer;
    begin
      val(value,d,code);
      if code<>0 then
        result:=false
      else
        result:=true;
    end;
      

  10.   

    --判断是否为数字
    if not tryStrToInt(edit2.text) then
      showmessage('输入值不是数字');