VB中计算图片随机变化次数

来源:百度知道 编辑:UC知道 时间:2024/05/13 19:46:15
程序开始运行时,图片在窗体范围内随机移动。当用户用鼠标点中该图片时,显示点中次数,每点中一次加10分
如果用label控件显示次数和分数呢,能不能改成循环结构的呢?谢谢

Dim s As Single
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 500 '设置变化速度
Picture1.AutoRedraw = True
End Sub

Private Sub Picture1_Click()
s = s + 10
label1.caption= "点中" & s/10 & "次,得分:" & S
End Sub

Private Sub Timer1_Timer()
Randomize
Dim x As Single, y As Single
With Picture1
x = Rnd * (Form1.ScaleWidth - .Width)
y = Rnd * (Form1.ScaleHeight - .Height)
.Move x, y
End With
End Sub