我这个delphi自定义函数存在什么问题?

[复制链接]
查看11 | 回复3 | 2009-10-17 09:07:55 | 显示全部楼层 |阅读模式
typeTrange=1..50;end;function txtbackcoler(const colernum:Trange):integer;//自定义函数begincase colernum of1..7: result:=1;8..15:result:=2;16..23: result:=3;24..32: result:=4;33..40: result:=5;end;
回复

使用道具 举报

千问 | 2009-10-17 09:07:55 | 显示全部楼层
不追求完美就不必理会这个警告。非要完美的话,在Case语句前加个返回值就行。...Result := 0;Case colernum of...
回复

使用道具 举报

千问 | 2009-10-17 09:07:55 | 显示全部楼层
只是警告而已.因为 如果colernum 是 41 你说你返回什么?所以case colernum of1..7: result:=1;8..15:result:=2;16..23: result:=3;24..32: result:=4;33..40: result:=5;else result:=0;end;
回复

使用道具 举报

千问 | 2009-10-17 09:07:55 | 显示全部楼层
先设默认值
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行