CnPack Forum


 
WanXiong
新警察
Rank: 1



UID 59799
Digest Posts 0
Credits 8
Posts 2
点点分 8
Reading Access 10
Registered 2011-3-3
Status Offline
Post at 2011-3-3 23:48  Profile | Blog | P.M. 
修改TCnSpinEdit

原代码:
function TCnSpinEdit.GetValue: LongInt;
begin
    Result:=StrToIntDef(Text,FMinValue);
end;
错误情况:
若Text存在小数点的情况,则结果取FMinValue

替换代码:
function TCnSpinEdit.GetValue: LongInt;
var
  E:Integer;
begin
  Val(Text, Result, E);
  if (E=1) then Result:=FMinValue;
end;
修改后情况:
如果Text中存在小数点(或其他字符),则按最前面的整数取值
至于最大最小值的处理,则由CheckValue进行,不需要在GetValue中做
E=1:第一个字符就是非数字

更进一步:
如果把值的类型变更为single,或Double,则使用就更方便了

修改之后,无权更新,只能发到这里了


WanXiong 于2011年3月3日
Top
 




All times are GMT++8, the time now is 2024-4-25 03:48

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.370369 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP