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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Randomizing images on a userform and stopping on click

Status
Not open for further replies.

jusfocuz

Programmer
Mar 26, 2007
9
US
I have been trying to figure out how I could show images on a VBA userform, but have this image keep changing until the user clicks on it.

the idea i have is to show different images of a die holding different numbers, and the user would click it to try and get a certain number.

any ideas?
thanks in advance
 
but how would i have the pictures keep changing until the user clicks on it? any ideas?
 
I have this so far:

Private Sub CommandButton1_Click()
Image1.Picture = LoadPicture("C:\Documents and Settings\Owner\Desktop\pic1.bmp")
Application.Wait Now() + TimeValue("00:00:01")
Image1.Picture = LoadPicture("C:\Documents and Settings\Owner\Desktop\pic2.bmp")
Application.Wait Now() + TimeValue("00:00:01")
Image1.Picture = LoadPicture("C:\Documents and Settings\Owner\Desktop\pic3.bmp")
Application.Wait Now() + TimeValue("00:00:01")
Image1.Picture = LoadPicture("C:\Documents and Settings\Owner\Desktop\pic4.bmp")
Application.Wait Now() + TimeValue("00:00:01")
Image1.Picture = LoadPicture("C:\Documents and Settings\Owner\Desktop\pic5.bmp")
Application.Wait Now() + TimeValue("00:00:01")

End Sub

Private Sub Image1_Click()
Unload UserForm1

End Sub


so when i show the userform, the pics begin to display one at a time, with 1 second intervals, and when i click it, the userform is closed. What i want to do is when i click it, the pics stop changing, it stays still.

then finally id like to see if there is a way to make an if statement, if the picture at which it was stopped is pic1 then msgbox "pic1" -- if the picture at which it was stopped is pic2 then msgbox "pic2" etc etc
 
Make an array with your pics file paths and then nest this in a do until button pressed loop
 
the array thing sounds great,how would such a loop look? how is "do until button pressed" translated into VBA code?

what i want to do is have the user click on the scrolling pics, to choose the one he/she wants.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top