Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move and resize a picture box VB 2008

Status
Not open for further replies.

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.
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top