关于一段循环代码的修改
本帖最后由 bcrun 于 2013-04-22 14:55:52 编辑
Private Sub Timer2_Timer()
Static i As Long
Dim j As Long
Dim C As Integer
For j = Picture6.lbound To Picture6.UBound
Picture6(j).Visible = False
Next j
Picture6(i).Visible = True
i = i + 1
'If Picture6(i).Picture.Handle = 0 Then Exit Sub
If i = j Then i = 0
End Sub
Private Sub Timer2_Timer()
Static i As Long, j As Long
Picture1(j).Visible = False
If Picture1(i).Picture.Handle Then
Picture1(i).Visible = True
j = i
End If
Do
i = (i + 1) Mod Picture1.Count
Loop Until Picture1(i).Picture.Handle
End Sub
Dim d As Object
Dim j As Long
Private Sub Form_Load()
Dim c As Long
Set d = CreateObject("scripting.dictionary")
For c = Picture6.LBound To Picture6.UBound
Picture6(c).Visible = False
If Picture6(c).Picture.Handle <> 0 Then
j = j + 1
d(j) = c
End If
Next c
End Sub
Private Sub Timer2_Timer()
Static i As Long
Dim k As Long
i = i + 1
If i > j Then i = 1
For k = 1 To j
Picture6(d(k)).Visible = (i = k)
Next
End Sub
Private Sub Timer2_Timer()
Static i As Long
Dim j As Long
Dim C As Integer
For j = Picture6.lbound To Picture6.UBound
Picture6(j).Visible = False
Next j
Picture6(i).Visible = True
i = i + 1
'If Picture6(i).Picture.Handle = 0 Then Exit Sub
'If i = j Then i = 0 '这句不要
'添加下面的代码:
For j = i To Picture1.UBound
If (Picture6(j).Picture.Handle) Then i = j: Exit Sub
Next
If (j > Picture1.UBound) Then i = 0
End Sub