当前位置:编程学习 > VB >>

新手请教

一个form中有多个控件,有text,command,combobox等。其中40个combobox中通过下拉(a,b,c和d)选择,并且没有使用combobox数组。
请教大侠:怎样统计这40个combobox中的内容为“b”的combobox的个数? --------------------编程问答-------------------- --------------------编程问答-------------------- http://zhidao.baidu.com/question/375602184.html?fr=fd --------------------编程问答-------------------- 遍历Controls数组 --------------------编程问答-------------------- 为啥不使用个数组? --------------------编程问答--------------------
引用 4 楼  的回复:
为啥不使用个数组?
\

同问 --------------------编程问答--------------------
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
--------------------编程问答-------------------- 添加一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 --------------------编程问答--------------------
引用 6 楼  的回复:
VB code

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 ……

顶 --------------------编程问答--------------------
引用 6 楼  的回复:
VB code
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

就是遍历整个窗口的控件,判断是否是combobox控件,是的话判断它的值是否是b,是就加1
补充:VB ,  控件
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,