你可以定义一个过程,传递的参数是TStringList
procedure GetEmployeeIDs(GonghaoList:TString);
const
  SQL_Select_ID  :string
    = 'Select EmployeeID From Employees';
begin
  GonghaoList.Clear;
  with TQuery.Create(Self) do begin
    DatabaseName := SysDB;
    SQL.Clear;
    SQL.Add(SQL_FromStat);
    Open;
    while not Eof do begin
      GonghaoList.Add(Fields[0].AsString);
      Next;
    end;    Close;
  end;
end;

解决方案 »

  1.   

    不知道有没有帮助,你看看了
    ...
    procedure GetEmployeeIDS(var GonghaoList: TStringList;);
    const
      SQL_Select_ID  :string
        = 'Select EmployeeID From Employees';
    begin
      with TQuery.Create(Self) do begin
        DatabaseName := SysDB;
        SQL.Clear;
        SQL.Add(SQL_FromStat);
        Open;
        while not Eof do begin
          GonghaoList.Add(Fields[0].AsString);
          Next;
        end;    Close;
        Free;
      end;
    end;
    ...
    procedure CallGetEmployeeIDS;
    var
      GonghaoList :TStringList;
    begin
      GonghaoList := TStringList.Create;
      try
        GetEmployeeIDS(GonghaoList);
      finally
        ...
        GonghaoList.Free;
        ...
      end;
    ...
    end;
    ...