Question:
How to make random pictures appear on the picturebox in VB 2005 Express?
2008-09-16 06:21:46 UTC
Microsoft visual basic 2005 Express.
how to make random pictures appear in the picture box?
What is the code??
It's for the design in my project. ^_^
Is it possible? I want random pictures appear on it.

Example, there are five pictures i want to be displayed in the picturebox in random. how??
Three answers:
Michel T
2008-09-16 06:50:30 UTC
One way of doing it is:



First you need to generate random numbers from 1 to 5 and store the value in an integer variable. Then all you have to do is use a swicth case in a timer object. Set the timer object to execute as often as you want the pictures to change,



i.e.



switch (randomNum)

{

case 1:

picBox.picture("Picture1")

break



case 2:

picBox.picture("Picture2")

break



etc...

}





This is pseudocode but you get the point!
andrea
2016-05-24 07:56:03 UTC
Just Choose Create New Project In Smart Device You Have Pocket PC Smartphone Windows CE Anyone Choose For Application Or What Do You Want And To Create Setup Choose Inside Other Project Type Setup And Deployment In Templates You Have Cab Project And Smart Device Cab Project
Matt
2008-09-16 06:42:33 UTC
You would need an array with the path to all your pics. EG:



Public picArr (1 to 4) as string

Public PicCount as integer

Private Sub Form_Load()

picArr(1)="c:/me.jpg"

picArr(2)="c:/myDog.jpg"

picArr(3)="c:/Airport.jpg"

picArr(4)="c:/pics/Madagascar.jpg"

PicCount=4

End Sub



Public Sub ChangePicture ()

dim x as decimal

x=rand(Now())

x=x*(picCount-1)

x=x+1

picBox1.picture=openpicture (picArr(cint(x)))

end sub



I think that's right... I stand to be corrected.

Hope you get it right,

Matt :)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...