if string = 'ftInteger' then FieldType := ftInteger
有没有别的方法, fieldtype里面有不少类型,我不可能写上2,30个if来判断的
用GetEnumValue,记得 uses TypInfo;
例子: type TFruits = (apples, pears);procedure FruitBeep (const fruitName : string); var Fruit : TFruits; begin Fruit := TFruits(GetEnumValue(TypeInfo(TFruits),fruitName)); case Fruit of apples : Windows.Beep (440, 100); pears : Windows.Beep (660, 100); end end;
FieldType := ftInteger
fieldtype里面有不少类型,我不可能写上2,30个if来判断的
uses
TypInfo;
type
TFruits = (apples, pears);procedure FruitBeep (const fruitName : string);
var
Fruit : TFruits;
begin
Fruit := TFruits(GetEnumValue(TypeInfo(TFruits),fruitName));
case Fruit of
apples : Windows.Beep (440, 100);
pears : Windows.Beep (660, 100);
end
end;