怎么判断文本框里输入的值不是数值型!

解决方案 »

  1.   

    if IntToStr(StrToInt(Edit1.Text)) = Edit1.Text then
      ShowMessage('是的')
    else
      ShowMessage('不是的');
      

  2.   

    s:=form1.Edit1.Text;
      i:=length(s);
      if i>0 then
      begin
        for j:=1 to i do
        begin
          a:=s[j];
          if (ord(a)>=49) and (ord(a)<=57) then
            showmessage('数字')
          else
            showmessage('非数字');
        end;
      end;
      

  3.   

    在Edit的onkeypress事件中
    if key not in ['0'..'9',#8] then key=#0这样输入的只能是数字
      

  4.   

    可参阅以下三种方法:
    一、if (strlcomp(pchar(copy(trim(db_name),1,1)),'0',1)>=0)
                   and(strlcomp(pchar(copy(trim(db_name),1,1)),'9',1)<=0) then
       showmessage('首字符不能位数字!');
    二、if Pos(Copy(Trim(db_name),1,1), '0123456789')>0 then
        Showmessage('首字符不能位数字!');
    三、 if (Not (Key in ['0'..'9','.'])) and (ord(Key)<>8) then
          Key:=#0;