jadams0173
Technical User
- Feb 18, 2005
- 1,210
I'm trying to move a picture box randomly around a form and make it smaller each time. I can't seem to get the picture box to move to the upper right and lower left.
Here is what I have so far.
Here is what I have so far.
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim point As New Point
Dim NewPicSizeX As Integer
Dim NewPicSizeY As Integer
Dim NewPicLocX As Integer
Dim NewPicLocY As Integer
Dim MaxPicLocX As New Random 'Integer = 256
Dim MaxPicLocY As New Random 'Integer = 171
Const ReduceBy As Double = 0.02
Timer1.Enabled = False
'new pic location
NewPicLocX = MaxPicLocX.Next(602)
NewPicLocY = MaxPicLocY.Next(411)
'MsgBox("x: " & NewPicLocX & vbCrLf & "Y:" & NewPicLocY)
'new pic size
NewPicSizeX = picCatch.Size.Width - CInt(picCatch.Size.Width * ReduceBy)
NewPicSizeY = picCatch.Size.Height - CInt(picCatch.Size.Height * ReduceBy)
picCatch.ClientSize = New Size(NewPicSizeX, NewPicSizeY)
point = New Point(NewPicLocX, NewPicLocY)
picCatch.Location = point
Timer1.Enabled = True
End Sub