How do you make a visual basic 2008 program display a random picture from a domain in a picture box?


yokozuna7 years ago
 1. create a random number generator that returns integers matching the number of pictures you have.

2.  assign a number to the path of each picture you want to be able to call up.

3.  call the path of the value your random generator creates.

If you're not worried about "random" and just want to rotate a few pics, that's a bit simpler- here's some code found on the web, in this case rotating six pics,  for such a purpose:

Public Sub RotatePic_Timer()

Static thispic As Integer

If thispic = 7 Then thispic = -1
thispic = thispic + 1

If (picRotate.Left) > ScaleWidth Then picRotate.Left = -100
picRotate.Picture = imgChrist(thispic).Picture

End Sub

thispic = (thispic+1) mod 7