PDA

View Full Version : VBA userForm: changing images



Olxa123
05-17-2009, 01:39 PM
hello!
My question will be about images in VBA forms.
I'm trying to create CHinese horoscope. But there is one thing I cannot manage with....

I have to change year of birth and everytime I change theyear the picture next to it has to be changed.

For instance, If I change the year to 1999 then the picture will show RABBIT...and so on...


Please, help me on this problem as quickly as possible!!!

Thank you in advance

P.S. The pictures needed in my work are in my excel workbook, but I still cannot "connect" years to these images.=(((((

mdmackillop
05-17-2009, 02:51 PM
Do you have a copy of the images in a folder? I think that would be easier to work with.

mdmackillop
05-17-2009, 03:12 PM
If you can load all the images into the userform, one on top of the other; set them to Visible = False. This can make the relevant image visible.

Private Sub TextBox1_AfterUpdate()
For i = 1 To 12
Me.Controls("Image" & i).Visible = False
Next
tmp = (CLng(TextBox1) Mod 12)+1
Me.Controls("Image" & tmp).Visible = True
End Sub

Olxa123
05-18-2009, 01:05 AM
well, if it can help you to understand I attached my excel file

mdmackillop
05-18-2009, 04:08 AM
This is really a workaround
Save the folder to the C drive. Images for years 2000 - 2002 added.

Olxa123
05-18-2009, 04:14 AM
thank you, but I cannot make it work...the button doesn't open the form

mdmackillop
05-18-2009, 05:05 AM
Probably a conversion issue, Delete and replace the button.