Dim OKG As BooleanPrivate Sub Form_Load() Dim H As Integer Dim W As Integer Dim T As Integer Dim L As IntegerT = Text1(0).Top L = Text1(0).Left H = Text1(0).Height W = Text1(0).Width Text1(0).Text = 0 Timer1(0).Interval = 100For o = 1 To 100 Load Timer1(o) Load Text1(o) Text1(o).Top = T Text1(o).Left = L Text1(o).Visible = True L = L + W + 30 If o Mod 10 = 0 Then T = T + H + 30 L = Text1(0).Left End If NextStatic I As Long I = 1 OKG = TrueEnd SubPrivate Sub Timer1_Timer(Index As Integer) If OKG Then Static I As Long I = I + 1 Text1(Index).Text = I * Index End If End Sub以上是代码,如果运算是简单就好正常全部TEXT控件都能看到变化,但是在TIME控件中加了个FOR Private Sub Timer1_Timer(Index As Integer) If OKG Then Static I As Long For p = 1 To 1000 I = I + 1 Text1(Index).Text = (I * Index) Next End If End Sub 就会有些控件不能作出反映,本人的思路是想用TIME控件做个简单的自治体
VB 中当两个TIMER重叠时,会有这种情况。
哈哈我只用过 1000个 Image来做 雪花飘, 100个Timer 天才啊....你倒不如用 Do...Loop 先加个Doevents再加上100个select case Num 让Num自动加1 100个事件轮着来.
2.timer线程,当一个timer被触发后,主进程将把控制权移交给这个线程,当又有其它timer被触发时,第一个timer和第二个timer的执行将是同步的而不是异步.LZ,为啥会出现这个问题,与timer的运行机制有关!
timer不是创建线程,而是往消息队列里面丢了一个消息而已。本质上说,相当于操作系统每隔一段时间按动一次按钮,或者按动一个菜单。
Dim H As Integer
Dim W As Integer
Dim T As Integer
Dim L As IntegerT = Text1(0).Top
L = Text1(0).Left
H = Text1(0).Height
W = Text1(0).Width
Text1(0).Text = 0
Timer1(0).Interval = 100For o = 1 To 100
Load Timer1(o)
Load Text1(o)
Text1(o).Top = T
Text1(o).Left = L
Text1(o).Visible = True
L = L + W + 30
If o Mod 10 = 0 Then
T = T + H + 30
L = Text1(0).Left
End If
NextStatic I As Long
I = 1
OKG = TrueEnd SubPrivate Sub Timer1_Timer(Index As Integer)
If OKG Then
Static I As Long
I = I + 1
Text1(Index).Text = I * Index
End If
End Sub以上是代码,如果运算是简单就好正常全部TEXT控件都能看到变化,但是在TIME控件中加了个FOR
Private Sub Timer1_Timer(Index As Integer)
If OKG Then
Static I As Long
For p = 1 To 1000
I = I + 1
Text1(Index).Text = (I * Index)
Next
End If
End Sub
就会有些控件不能作出反映,本人的思路是想用TIME控件做个简单的自治体