ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   various (https://www.excelbanter.com/excel-programming/319249-various.html)

Mauro

various
 
I would like to end a job with some humor. Is it possible to randomly show
pictures or userforms when closing an userform?



Lonnie M.

various
 
Mauro, try something like this:

Private Sub UserForm_initialize()
Dim myMax%, myMin%, myImageNumber%
Dim myImage$
myMax = 5
myMin = 1
myImageNumber = Round(Rnd * (myMax - myMin) * myMin + 1)
myImage = "D:\macros\Images\" & _
Round(Rnd * (myMax - myMin) * myMin + 1) & ".gif"
MsgBox myImage
Image1.Picture = LoadPicture(myImage)
End Sub

Regards, Lonnie M.


Lonnie M.

various
 
Mauro, Try this:

Private Sub UserForm_initialize()
Dim myMax%, myMin%, myImageNumber%
Dim myImage$
myMax = 5
myMin = 1
myImageNumber = Round(Rnd * (myMax - myMin) * myMin + 1)
'Be sure to change the directory to where your images are
myImage = "D:\macros\Images\" & myImageNumber & ".gif"
MsgBox myImage
Image1.Picture = LoadPicture(myImage)
End Sub

Regards, Lonnie M.


Lonnie M.

various
 
Mauro, Try this:


Private Sub UserForm_initialize()
Dim myMax%, myMin%, myImageNumber%
Dim myImage$
'Use whatever min or max values you want
myMax = 5
myMin = 1
myImageNumber = Round(Rnd * (myMax - myMin) * myMin + 1)
'Be sure to change the directory to where your images are


myImage = "D:\macros\Images\" & myImageNumber & ".gif"
Image1.Picture = LoadPicture(myImage)
End Sub

Regards, Lonnie M.



All times are GMT +1. The time now is 08:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com