Delphi case statement for integer ranges

后端 未结 1 1126
时光取名叫无心
时光取名叫无心 2021-02-20 15:51

I have a function which is being passed an integer value, representing a step value. There are 5 seperate conditions I want to test for: Value =0 Value =1 Value =-1 Value >1 Va

1条回答
  •  萌比男神i
    2021-02-20 16:33

    var
      MyValue: integer;
    
    ...
    
    case MyValue of
      Low(Integer)..-2:
        beep;
      -1:
        beep;
      0:
        beep;
      +1:
        beep;
      2..High(Integer):
        beep;
    end;
    

    0 讨论(0)
提交回复
热议问题