vb中咋样让图片随机位置循环出现。 10
2个回答
展开全部
随机位置循环,这里一共是6次
Dim x(6), y(6) As Long
Private Sub Command1_Click()
For i = 0 To 5
Randomize
x(i) = Int(Rnd() * Me.Width)
y(i) = Int(Rnd() * Me.Height)
Next
Timer1.Enabled = 1
End Sub
Private Sub Form_Load()
With Timer1
.Enabled = 0
.Interval = 500
End With
End Sub
Private Sub Timer1_Timer()
Static a As Long
If a < 6 Then
With Picture1 '在窗体大小的范围内随机循环移动
.Left = x(a)
.Top = y(a)
End With
a = a + 1
If a = 6 Then a = 0
End If
End Sub
Dim x(6), y(6) As Long
Private Sub Command1_Click()
For i = 0 To 5
Randomize
x(i) = Int(Rnd() * Me.Width)
y(i) = Int(Rnd() * Me.Height)
Next
Timer1.Enabled = 1
End Sub
Private Sub Form_Load()
With Timer1
.Enabled = 0
.Interval = 500
End With
End Sub
Private Sub Timer1_Timer()
Static a As Long
If a < 6 Then
With Picture1 '在窗体大小的范围内随机循环移动
.Left = x(a)
.Top = y(a)
End With
a = a + 1
If a = 6 Then a = 0
End If
End Sub
追问
用的是image。
追答
把Picture1改成Image1
他们都有Top Left属性的
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主是用picturebox,用pictureload装载是吧。
那将picturebox的坐标做成随机的不就行了吗?
那将picturebox的坐标做成随机的不就行了吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |