procedure Tfrmqxgl_cdsz.BitBtn2Click(Sender: TObject);
var
     j: integer;
begin
  if combobox1.Text<>'' then
    begin
     if (self.ListBox2.Items.Count = 0) and (self.ListBox1.Items.Count <> 0) then
          self.ListBox2.Items[0] := self.ListBox1.Items[0];
     for j := 0 to self.ListBox1.Items.Count - 1 do
     begin
          if self.checklistbox(ListBox1.Items[j]) then
            begin
               self.ListBox2.Items.Add(ListBox1.Items[j]);
               table2.Append;
               table2.FieldByName('组号').AsString:='0';
               table2.FieldByName('功能项').AsString:=ListBox1.Items[j];
            end;
     end;
  end
  else
     Application.MessageBox('用户没有选定!','信息提示',mb_ok);
end;
没有提示任何错误,只是执行结果和实际不对,listbox2中的第一条记录没有能添加到数据表中!

解决方案 »

  1.   

    少了一个else begin ...end;
      

  2.   

    不太能明白你的意思,你是不是大体指:
    procedure Tfrmqxgl_cdsz.BitBtn2Click(Sender: TObject);
    var
         j: integer;
    begin
      if combobox1.Text<>'' then
       begin
         if (self.ListBox2.Items.Count = 0) and (self.ListBox1.Items.Count <> 0) then
         begin
           self.ListBox2.Items[0] := self.ListBox1.Items[0];
           for j := 0 to self.ListBox1.Items.Count - 1 do
             begin
                if self.checklistbox(ListBox1.Items[j]) then
                  begin
                    self.ListBox2.Items.Add(ListBox1.Items[j]);
                    table2.Append;
                     table2.FieldByName('组号').AsString:='0';
                    table2.FieldByName('功能项').AsString:=ListBox1.Items[j];
                 end;
         end;
      end
      else
         Application.MessageBox('用户没有选定!','信息提示',mb_ok);
    end;