当前位置:主页>仓库管理软件> 列表

数据类型校验的问题,高分求一函数 找药品进销存软件

库存管理软件版1楼: 求一函数 function CheckOutDataType(FieldType:TFieldType;aCharacter:string):Boolean;
其中FieldType为数据库中的字段的类型,例如ADOQuery1.Fields.Fields[1].DataType
aCharacter为字符类型(固定的)
要求:if aCharacter(字符类型)=FieldType数据类型 then
//判断aCharacter(字符类型)是否=FieldType数据类型,是返回True
result := true
else //不相等
begin
if 转换aCharacter(字符类型)=FieldType数据类型 then
//不相等的话,能不能把aCharacter(字符类型)转化为FieldType数据类型
result := true //能转化,为True
else
result := false; //不能转化,为False
end;

2楼: 高手呢
在简单点
怎样判断两个数据类型是否一样 如药品进销存软件

3楼: function CheckOutDataType(AFieldType : TFieldType):Boolean;
begin
if AFieldType in [ftString, ftMemo, ftWideString, ftFmtMemo] then
result := true//如果是字符串


else
begin
if AFieldType in [ftSmallint, ftInteger, ftLargeint, ftWord, ftFloat, ftCurrency, ftBCD, ftAutoInc] then
result := true//如果可以转换为字符串
else
result := false;
end;
end;

4楼: 没有人回答
自顶

5楼: 呵呵
我刚自己解决
就有人发帖
不过还是要谢谢你
结帖

6楼: 多人接受答案了。