OleVariant类型一般做什么用?怎么用?

解决方案 »

  1.   

    OleVariant一般做为参数的传递。例如:
    在一个类中有这样一个过程:
    procedure select(V:OleVariant);
    begin
      neibuzy_Qry.Close;
      neibuzy_Qry.SQL.Clear;
      sqlstr:=' select * from tb_employ where 1=1 ';
      if not VarIsNull(v[0]) then
        sqlstr:=sqlstr+' and employecode='''+Vartostr(v[0])+'''';
      if not VarIsNull(v[1]) then
        sqlstr:=sqlstr+' and fullname='''+Vartostr(v[1])+'''';
      if not VarIsNull(v[2]) then
        sqlstr:=sqlstr+' and name='''+Vartostr(v[2])+'''';
      if not VarIsNull(v[3]) then
        sqlstr:=sqlstr+' and shortcode='''+Vartostr(v[3])+'''';
      neibuzy_Qry.SQL.Add(sqlstr);
      neibuzy_Qry.Open;
    end;在另一个单元要调用时,则:类名.select(vararrayof([参数列表]));
    就可以了,你去试试吧!