delphi中的Case使用方法及DIV及MOD千分位、百分位、十位的截取

1.Case的格式

case <表达式> of
     <数值>:<语句>;
     <数值>:<语句>;
else
     <语句>;
end;

实例1说明

case id of
     1:result := 99;
     2:result := 98;
else
     result := 97;
 end;

实例2说明

case id:integer of
     1..9 : begin
              result := 99;
            end;
     10 :  begin
             result := 98;
           end;
  else:  begin
           result := 100;
         end;
  end;

2.Div及Mod千分位、百分位、十位的截取

x1 = y1 div 1000 ; //取千分位
x2 = (y2 mod 1000) div 100 ; //取百分位
x3 = (y3 mod 100) div 10 ; //取十分位

piDev_No := 1100;//本次假设1100
iFloor := piDev_No div 1000;//取千分位
iArea  := (piDev_No mod 1000) div 100; //取百分位
iSec   := (piDev_No mod 100) div 10;; //取十分位
 case iFloor of
     1:begin
         case iArea of
              1:begin
                 case piDev_No of
                    1101: result := 0;
                    1102: result := 1;
                  end; 
               end;
             2:begin
                case piDev_No of
                    1201: result := 2; 
                    1202: result := 3; 
                  end;
               end;
             3:begin
                 case piDev_No of
                    1301: result := 4;
                  end; 
               end;
         end;
    2:begin
         case iArea of
             1:begin
                 case piDev_No of
                   2101: result := 4; 
                 end;
               end;
             2:begin
                 case piDev_No of
                   2201: result := 5; 
                  end;
               end;
             3:begin
                  case piDev_No of
                     2301: result := 5; 
                   end;
               end;
         end;
 end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值