vb中几个combobox里面有数字1~9,随意将这几个combobox选几个数,如何检测这几个数是否相同?
combo1(0),combo1(9),combo1(18),combo1(27),combo1(326),combo1(45),combo1(54),combo1(63...
combo1(0),combo1(9),combo1(18),combo1(27),combo1(326),combo1(45),combo1(54),combo1(63),combo1(72),combobox里面有数字1~9,如何检测这几个数是否相同,相同text1则显示“通过”,不通则显示“数字重复”。急要。
展开
1个回答
展开全部
dim i as integer
dim oC as Control
dim num() as integer
i=-1
'1 取出数据存入数组
for each oc in me.controls
if typeof oc is combobox then
if oc.name="combo1" then
i=i+1
redim num(i)
num(i)=oc.list(oc.listindex)
end if
endif
next
‘2 进行比较
if i<1 then exit sub
for i =1 to ubound(num)
if num(i)<>num(0) then
exit for
endif
next
if i<ubound(num)+1
text1="数字重复"
else
text1="通过"
end if
dim oC as Control
dim num() as integer
i=-1
'1 取出数据存入数组
for each oc in me.controls
if typeof oc is combobox then
if oc.name="combo1" then
i=i+1
redim num(i)
num(i)=oc.list(oc.listindex)
end if
endif
next
‘2 进行比较
if i<1 then exit sub
for i =1 to ubound(num)
if num(i)<>num(0) then
exit for
endif
next
if i<ubound(num)+1
text1="数字重复"
else
text1="通过"
end if
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询