Dim atime As LongPrivate Sub Form_Load()
atime = 0
End SubPrivate Sub Timer1_Timer()
atime = atime + 1If atime = 1 Then
A.Visible = True
ElseIf atime = 2 Then
B.Visible = True
A.Visible = False
ElseIf atime = 3 Then
C.Visible = True
B.Visible = False
ElseIf atime = 4 Then
D.Visible = True
C.Visible = False
ElseIf atime = 5 Then
E.Visible = True
D.Visible = False
ElseIf atime = 6 Then
F.Visible = True
E.Visible = False
ElseIf atime = 7 Then
G.Visible = True
F.Visible = False
ElseIf atime = 8 Then
H.Visible = True
G.Visible = False
ElseIf atime = 9 Then
I.Visible = True
H.Visible = False
ElseIf atime = 10 Then
J.Visible = True
I.Visible = False
ElseIf atime = 11 Then
K.Visible = True
J.Visible = False
ElseIf atime = 12 Then
L.Visible = True
K.Visible = False
End If
End Sub
我应该怎么让它循环起来?

解决方案 »

  1.   

    什么ABCDEFGHIJK啊我知道你想要做什么干嘛不把控件编上号。访问的时候就这样A(0).Visible=true
    A(1).Visible=false什么?不会编号?两个办法:
    1、控件选定,Ctrl+C,Ctrl+V。然后问你是否XXX,选是
    2、控件选定,设置Index属性
      

  2.   

    可以用 DO LOOP否?来循环?
      

  3.   

    你的atime不会是无限的累加吧,从你的代码中估计是1-12中的循环。
    你把ABCDEFGHIJKL等控件做成控件数组(如果是同一种控件),如;Text1(0)-Text1(11)
    Text1(0)对应你的A,Text1(11)对应你的L
    在你的代码中L控件一直没被隐藏,不知是笔误还是题意就是这样,我就按笔误来做
    代码如下:
    Dim atime As IntegerPrivate Sub Timer1_Timer()
       atime = atime + 1
       If atime > 12 Then
          atime = 1
       End If
       
       Text1(atime - 1).Visible = True
       If atime > 1 Then
          Text1(atime - 2).Visible = False
       ElseIf atime = 1 Then
          Text1(11).Visible = False
       End If
    End Sub
      

  4.   

    在你的代码上稍加修改即可:
    Dim atime As LongPrivate Sub Form_Load()
    atime = 0
    End SubPrivate Sub Timer1_Timer()
    atime = atime + 1If atime = 1 Then
    A.Visible = True
    L.Visible = False
    ElseIf atime = 2 Then
    B.Visible = True
    A.Visible = False
    ElseIf atime = 3 Then
    C.Visible = True
    B.Visible = False
    ElseIf atime = 4 Then
    D.Visible = True
    C.Visible = False
    ElseIf atime = 5 Then
    E.Visible = True
    D.Visible = False
    ElseIf atime = 6 Then
    F.Visible = True
    E.Visible = False
    ElseIf atime = 7 Then
    G.Visible = True
    F.Visible = False
    ElseIf atime = 8 Then
    H.Visible = True
    G.Visible = False
    ElseIf atime = 9 Then
    I.Visible = True
    H.Visible = False
    ElseIf atime = 10 Then
    J.Visible = True
    I.Visible = False
    ElseIf atime = 11 Then
    K.Visible = True
    J.Visible = False
    ElseIf atime = 12 Then
    L.Visible = True
    K.Visible = False
    atime=0
    End If
    End Sub
    加了两句代码,看能不能达到你的要求。
      

  5.   

    给控件编号是不错的办法
    你所使用的方法是会在初学的时候出现,想的时候往深一点想就好了,还有就是现在没接触那么多,所以会出现这样的问题,
    还好你会用Csdn,这是个不错的地方!
    常用它你会比和你同起步的的学者进步的更快
    给控件的index设置值,等到为最大的时候在回到初始值就应该是你要得答案了
    可能还有更好的办法,想起来了在告诉你!呵呵!
      

  6.   

    注意,控件是可以有数组的
    那么
    Private Sub Timer1_Timer()
     atime = atime + 1
     for i=0 to 11
      A(i).visible = false
     next i
     A(atime).visible = true
    End Sub