you could do it vb helper's way or you can use a DoLoop and randomly throw a picturebox all over the place also. I haven't tested it, but it should work. All you need is a command button and a picturebox
Code:
Dim GetScreenHeight As Integer, GetScreenWidth As Integer 'Screen
Dim CurrentXPos As Long, CurrentYPos As Long, RandomX As Long, RandomY As Long 'X&Y Values
Private Sub cmdAnimation_Click()
If frmMain.WindowState = 2 Then 'incase if Form was maximized already then set to Normal
'or it will cause error
WindowState = 1
End If
GetScreenHeight% = Screen.Height
GetScreenWidth% = Screen.Width
If cmdAnimation.CausesValidation = True Then
frmMain.Height = GetScreenHeight% 'Set Y
frmMain.Width = GetScreenWidth% 'Set X
RunScreenSaver
moveRandom = 1
End If
End Sub
Private Function RunScreenSaver()
Dim moveRandom As Integer
PicBox.Visible = True 'Set Default as False to show it at a later time
Do 'Start Repeat
Randomize 'Initializes Random-Generator | rnd() |
CurrentXPos& = PicBox.Left 'Get X
CurrentYPos& = PicBox.Top 'Get Y
RandomX& = CurrentXPos& + Rnd(10)
RandomY& = CurrentYPos& + Rnd(10)
PicBox.Move RandomX&, RandomY&
If moveRandom% > 19999 Then
moveRandom% = 0
RandomX& = Rnd(1000)
End If
If Me.Width < RandomX& - 200 Then
PicBox.Move Rnd() * ScaleWidth, Rnd() * ScaleHeight 'Blow-Back effect randomly across screen
End If
If Me.Height < RandomY& - 200 Then
PicBox.Move Rnd() * ScaleWidth, Rnd() * ScaleHeight 'Blow-Back effect randomly across screen
End If
DoEvents 'Yield
moveRandom% = moveRandom% + 1
WindowState = 2
Loop 'Repeat
End Function
Bookmarks