一个form中有多个控件,有text,command,combobox等。其中40个combobox中通过下拉(a,b,c和d)选择,并且没有使用combobox数组。
请教大侠:怎样统计这40个combobox中的内容为“b”的combobox的个数?

解决方案 »

  1.   

    http://zhidao.baidu.com/question/375602184.html?fr=fd
      

  2.   

    dim oCtl as control
     dim Nums as long
     
     for each octl in me.controls
         if typename(octl)="ComboBox" then
             if octl.text="b" then nums=nums+1
         end if
     next
     
     msgbox nums
      

  3.   

    添加一click事件,输入以下代码就行:
    dim a as control
     dim s as long
     
     for each a in me.controls
         if typename(al)="ComboBox" then
             if al.text="b" then s=s+1
         end if
     next
     
     print s
      

  4.   

    就是遍历整个窗口的控件,判断是否是combobox控件,是的话判断它的值是否是b,是就加1