for j := 1 to Seriallength do
begin
if Serialtype = 10 then
begin
CheckStr := UpperCase(Copy(barcode,j,1));
if not (CheckStr[1] in ['0','1','2','3','4','5','6','7','8','9']) then
Result := false
else
Result := true;
end
begin
if Serialtype = 10 then
begin
CheckStr := UpperCase(Copy(barcode,j,1));
if not (CheckStr[1] in ['0','1','2','3','4','5','6','7','8','9']) then
Result := false
else
Result := true;
end
解决方案 »
- 谁有空的,帮忙写一个小程序!
- 大侠们,关于停靠(dock)的问题,解决后有重分相谢~~~~~~~
- 看这个DELPHI代码问题!COMBOBOX问题
- 如何利用ClientDataSet的commandtext 属性动态查询? 在线等待
- 在线急等 请教 不盛感激
- 为什么我用ADO连接ORACLE数据库,在开发环境下可以打开ADOConnection的连接,但程序运行时却不行呢?
- 100分,关于对话框问题>>>>>>
- 关于文件解压缩的问题!?
- 谁有支持自开发控件XP风格化的东东?
- 如何生成文件型“数据库”?
- drawgrid画图之后图像闪动很严重,求指点
- 两个datetimepicker控件 取一段时间的数据
CheckStr := UpperCase(Copy(barcode,j,1));
这句是把barcode从j开始1个字符转大写赋给CheckStrCheckStr[1] in是判断CheckStr第一个字符是否在['0','1','2','3','4','5','6','7','8','9']范围内
for j := 1 to Seriallength do
begin
if Serialtype = 10 then
begin
CheckStr := UpperCase(Copy(barcode,j,1));//取barcode的第j个字符
//如果CheckStr的第一个字符(实际上这个字符串就一个字符),不是0到9(不是数字)就返回值为false,否则返回值为true
if not (CheckStr[1] in ['0','1','2','3','4','5','6','7','8','9']) then
Result := false
else
Result := true;
end
这段代码的意思就是:扫描barcode这个字符串,
如果Serialtype不是10,继续循环,
如果是10,进行下列判断:
详见上面注释,这段代码的结果就是:
如果Serialtype不是10,继续循环,
如果是10
如果barcode[Seriallength]是数字就返回true不是就返回false
代码可简化为:
if Serialtype = 10 then
result :=barcode[Seriallength] in ['0','1','2','3','4','5','6','7','8','9'];