比如我想判断一个控件数组是否相等
If Command1(0).Caption=1 And Command1(1).Caption=1 And Command1(2).Caption=1 Then
Print "A"
End If
如果Command1 控件有100个呢???怎么判断?? 难道要写100个 判断试?
我想有其他方法吧
请高手指点
比如我想判断一个控件数组是否相等
If Command1(0).Caption=1 And Command1(1).Caption=1 And Command1(2).Caption=1 Then
Print "A"
End If
如果Command1 控件有100个呢???怎么判断?? 难道要写100个 判断试?
我想有其他方法吧
请高手指点
2007-01-21 18:36

2007-01-21 18:48
2007-01-21 19:06

2007-01-21 19:29
你的意思是不是必須全部是caption為1才輸出A 要是這樣的話..可以像下面這樣做
for i=0 to 100
if command1(i).caption <> "1" then exit for
if i=100 and command1(100).Caption="1" then print "A" '少写了
怎么看 就这么别扭 原来你写错啦

2007-01-21 19:42
for i=0 to 100
if command1(i).caption <> "1" then exit for
if i=100 and command1(100).Caption="1" then print "A"
next i
这段代码可以实现 我想要的 判断效果哟 刚刚试过了
判断Command1(0).Caption 到Command1(100).Caption =1 输出A

2007-01-21 19:51
这样就可以 否则运行不到想要的效果哦

2007-01-21 20:00
不会呀 把IF 放到里面只输出一次 因为当i>100的时候 是不输出的 如果在i>100情况下 就有出现不等于1的 就直接结束For循环了
[此贴子已经被作者于2007-1-21 20:05:18编辑过]

2007-01-21 20:04
真的不行哦 一定要把NEXT I放到 IF 下面

2007-01-21 20:21
别那么拿多 那8个来做实验
Dim i As Integer
Private Sub Command2_Click()
For i = 0 To 7
If Command1(i).Caption <> "1" Then Exit For
If i = 7 Then Print "A"
Next i
End Sub
如果全部等于1可以 输出A
Dim i As Integer
Private Sub Command2_Click()
For i = 0 To 7
If Command1(i).Caption <> "1" Then Exit For
Next i
If i = 7 Then Print "A"
End Sub
放上去者不行

2007-01-21 20:23