vb 使用问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 14:59:09
如何使单击窗体后每1秒重复执行下列代码,直到下次单击结束,最好用time控件。Dim x1, y1, i As Integer
Scale (-320, 320)-(320, -320)
For i = 1 To 200
DrawWidth = 6
x1 = 300 * Rnd
y1 = 300 * Rnd
If Rnd < 0.5 Then x1 = -x1
If Rnd < 0.5 Then y1 = -y1
PSet (x1, y1), QBColor(Rnd * 15)
Next i

Dim a As Boolean

Private Sub Form_load()
a = True
End Sub

Private Sub Form_Click()
If a = True Then
a = False
Timer1.Interval = 1000
Else
a = True
Timer1.Interval = 0
End If
End Sub

Private Sub Timer1_Timer()
Dim x1, y1, i As Integer
Scale (-320, 320)-(320, -320)
For i = 1 To 200
DrawWidth = 6
x1 = 300 * Rnd
y1 = 300 * Rnd
If Rnd < 0.5 Then x1 = -x1
If Rnd < 0.5 Then y1 = -y1
PSet (x1, y1), QBColor(Rnd * 15)
Next i
End Sub