在该Data.DB单元中,声明了以下枚举:
TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord, ftBoolean, ftFloat, ...)
Run Code Online (Sandbox Code Playgroud)
我需要确定DataType搜索网格中的字段是否是整数、字符串、浮点数、日期、blob 等。
Integer 应该是任何可以用作整数的类型,例如ftSmallint、ftInteger、ftWord等。
有没有比下面更短的方法来做到这一点?
if (Field.DataType = ftInteger) or (Field.DataType = ftSmallint) or (Field.DataType = ftWord) then Result := ftInteger;
Run Code Online (Sandbox Code Playgroud)
你可以这样做
if Field.DataType in [ftInteger, ftSmallInt, ftWord] then ...
Run Code Online (Sandbox Code Playgroud)
另外,您可以将集合类型定义为 aset of TFieldType并使用该类型的变量来存储您要查找的字段类型,然后使用if Field.DataType in ...它。
| 归档时间: |
|
| 查看次数: |
2474 次 |
| 最近记录: |