入力された整数の確認をするには?

解決


ペェージ  2004-12-20 00:05:11  No: 12390  IP: [192.*.*.*]

InputQueryで整数を入力し、その整数が、ある範囲内にあるかを確認したいのです。
以下のソースを書いてみたのですが、実行して整数0〜10までを入力してみると、3,7,8,9,10しか反応してくれません。ソースに何か問題があるのでしょうか?どなたか、教えてください。よろしくお願いします。

---------------------------------------------------------------

 var
   s : string;
   B : set of byte;
begin
  if InputQuery('数字の入力','整数を入力してください',s) then
  begin
    try
      if StrToInt(s) in B then
      begin
        ShowMessage(s);
      end;
    except
      on EConvertError do ShowMessage('整数か?');
    end;
  end;
end;

編集    削除
大豆Z  2004-12-20 01:41:11  No: 12391  IP: [192.*.*.*]

上のは  
 if InputQuery('数字の入力','整数を入力してください',s) then
の1行上に
B := [1,2,3,4,5,6,7,8,9,10];
とすると  全部反応しますけど?
3,7,8,9,10のみ反応なら
B := [3,7,8,9,10];

-----------------------------------------------------------
  var i : integer;
      s : string;
      Dot : Boolean;
begin
  s := Edit1.Text;
  Dot := True;  // 整数ならTrue設定,少数扱う場合は、False設定
  if Length(s)=0 then  ShowMessage('数字を入力してください');
  for i := 1 to Length(s) do
   begin
     case s[i] of
       //'0'..'9' : continue;
       '0','1','2','3','4','5','6','7','8','9' : continue;
       else
        begin
          if (s[i] = '.')and(not Dot) then
            begin Dot := True; continue end;
          if (i =1)and(s[1]='-') then continue;
           ShowMessage(s+' '+s[i]+' は、数字ではありません'
               +#13#10
               +'数字を入力してください');
           Break;
        end;
       end; // case
   end;
end;

編集    削除
ペェージ  2004-12-20 02:32:01  No: 12392  IP: [192.*.*.*]

どうもありがとうございます。確かに出来ました。

編集    削除