把40个checkbox定义成对象数组carray:array[1..40] of tcheckbox,怎么在程序中用carray[i],我主要想用checkbox的checked的属性。我在窗体上有40个checkbox,一个button,button的单击事件是
   for i:=1 to 40 
        if carray[i].checked:=true then
              n:=n+1;
但此程序在运行时出现错误,请高手帮忙

解决方案 »

  1.   

    for i:=1 to 40 do
            if carray[i].checked = true then
                  n:=n+1;
      

  2.   

    if carray[i].checked:=true then
    变成if carray[i].checked=true then
      

  3.   

    for i:=1 to 40 do
      begin 
      if carray[i].checked:= true
      n:=n+1;
      continue;
      end;
      

  4.   

    这么多的CheckBox可以用TCheckListBox代替啊
      

  5.   

    我觉得楼主可能是提问的时候打错了,不然怎么可能到运行时才报错?
    根本编译不了嘛:)
       楼主也没贴全
    可能是没写
       for i := 1 to 40
          carray[i] := TCheckBox.Create(Self);
      

  6.   

    就算是if Checked = True then也挺滑稽~~~if Checked then不好吗???