变体类型作参数一例

function FunArrConst(const Value: array of const):string;
var
  i: Integer;
  OrigNum:string;
begin
  for i := Low(Value) to High(Value) do
    with Value[i] do
      case VType of
        vtAnsiString: OrigNum := OrigNum +' '+ string(VAnsiString);
        vtInteger: OrigNum := OrigNum +' '+ IntToStr(VInteger);
        vtBoolean: OrigNum := OrigNum +' '+ BoolToStr(VBoolean);
        vtChar: OrigNum := OrigNum +' '+ VChar;
        vtExtended: OrigNum := OrigNum+' ' + FloatToStr(VExtended^);
        vtString: OrigNum := OrigNum +' '+ VString^;
        vtPChar: OrigNum := OrigNum +' '+ VPChar;
        vtObject: OrigNum := OrigNum+' ' + VObject.ClassName;
        vtClass: OrigNum := OrigNum +' '+ VClass.ClassName;
        vtCurrency: OrigNum := OrigNum +' '+ CurrToStr(VCurrency^);
        vtVariant: OrigNum := OrigNum+' ' + string(VVariant^);
        vtInt64: OrigNum := OrigNum +' '+ IntToStr(VInt64^);
      end;
      Result:=OrigNum;
end;
//调用
var
  cls:TControlClass;
begin
  cls:=TComboBox;
  ShowMessage(FunArrConst(['hello',255,9.66,$Fc,#66,False,cls]));
end;

你可能感兴趣的:(变体类型作参数一例)