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!

VBA userform help, displaying pictures

Status
Not open for further replies.

jusfocuz

Programmer
Mar 26, 2007
9
US
Hi, I was wondering If anyone could help me with something I have been trying to figure out. Is there a way I could make a userform,insert two image boxes on it, and then somehow code it so that according to the users input, two different pictures would show.

for example, if i ask the user for his/her favorite color, and if they say blue, the userform will show two blue pictures, if they say red it'll show to red pictures.. etc

thanks in advance
 
jusfocuz

Do you want pictures or colors. If you just want colors you can just use a lable and change its backcolor property.

when they click the button use

Private Sub Command1_Click()
Label1.BackColor = vbRed
End Sub
 
i want to use pics. but would that be a similar code. ex:

Private Sub Command1_Click()

if a = 1 then
Image1.Picture = (and the destination of the file)
else
Image1.Picture = (a different destination of the other file)

End Sub
 

Try:
Code:
If a = 1 then
  Image1.Picture = LoadPicture("C:\text\red.jpg")
Else
  Image1.Picture = LoadPicture("C:\text\green.jpg")
End If


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top