-
VBA userForm: changing images
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.=(((((
-
Do you have a copy of the images in a folder? I think that would be easier to work with.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
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.
[vba]
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
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
well, if it can help you to understand I attached my excel file
-
This is really a workaround
Save the folder to the C drive. Images for years 2000 - 2002 added.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
thank you, but I cannot make it work...the button doesn't open the form
-
Probably a conversion issue, Delete and replace the button.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules