~因为明天要交~所以没时间想var  s:string;
begin
  s:=StringOfChar('0',32);
  if Chk01.Checked then s[1]:='1';
  if Chk02.Checked then s[2]:='1';
  if Chk03.Checked then s[3]:='1';
  if Chk04.Checked then s[4]:='1';
  if Chk05.Checked then s[5]:='1';
  if Chk06.Checked then s[6]:='1';
  if Chk07.Checked then s[7]:='1';
一共有32个...怎么简化
Chk01是复选框~谢谢

解决方案 »

  1.   

    统一放置到一个PANEL上
     for i := 0 to ControlCount - 1 do
        begin
          if Controls[i].ClassType = TCheckBox then
          根据命名的规则获得名称后面的数字 Copy(Controls[i].Name, x, N);
    这个数字作为数组的下标这样就可以完成你所说的功能了吧
      

  2.   

    var str:string;str:=''
    for i:=1 to componentcount do
    begin
    if i<10 then str:='chk0'
       else str:='chk'
    if TCheckBox(FindComponent(str+inttostr(i)).checked then
       s[i]:='1';
    end;
      

  3.   

    angle097113(深思不解) 和whbo(王红波(年轻人,要有所作为))两大侠就是牛。
      

  4.   

    接angle097113(深思不解) 大侠的:With panel1 do begin
     for i := 0 to ControlCount - 1 do
        begin
          if Controls[i].ClassType = TCheckBox then 
              if Controls[i].Checked then 
                s[StrToInt(Copy(Controls[i].Name,6,2))] := '1';
              end 
    end;