Text box change to load two pictures

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,199
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have the code below which works fine.
I have now added another Image box called Image2 and asking for some advice please in reference to also load a second photo into it.

Currently the working code below only loads a photo into Image1.
I am looking for advice to edit the code so at the same time also load a photo into Image2

Code:
Private Sub TextBox10_Change()If Me.TextBox10.Value = "HU 64" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU64.jpg")
ElseIf Me.TextBox10.Value = "HU 66 GEN 1" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU66GEN1.jpg")
ElseIf Me.TextBox10.Value = "HU 66 GEN 2" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU66GEN2.jpg")
ElseIf Me.TextBox10.Value = "HU 66 GEN 3" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU66GEN3.jpg")
ElseIf Me.TextBox10.Value = "HU 92" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU92.jpg")
ElseIf Me.TextBox10.Value = "HU 100" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU100.jpg")
ElseIf Me.TextBox10.Value = "HU 101" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU101.jpg")
ElseIf Me.TextBox10.Value = "NSN 14" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\NSN14.jpg")
ElseIf Me.TextBox10.Value = "SIP 22" Then
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\AWAITINGIMAGE.jpg")
End If
End Sub

Many Thanks & have a nice day.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
ok so you have text box and based on what you type in there, it loads a picture into "image 1".

(putting aside a point that combo box is probably a better choice than text box)

is the image 2 going to be based off of same text box or a separate text box?
scenario 1: based on the same textbox (textbox10) both image1 and 2 gets updated
Code:
Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\REMOTES ETC\LOCK PICKING IMAGES\HU64.jpg")
Image2.Picture = LoadPicture("XXX")'put in the link
ElseIf Me.TextBox10.Value = "HU 66 GEN 1" Then '...continue to put in image2.picture for every choice

scenario 2 - Image 2 based on a separate text box
change all Image1.picture to image2.picture. update the name of the textbox from textbox10 to whatever the new text box is

scenario 3 - Image 2 is based on same text box, but the code should load either image 1 or image 2 (not both)
at the end of your current code, add on
Code:
[COLOR=#333333]ElseIf Me.TextBox10.Value = "ABCD" Then
[/COLOR][COLOR=#333333]Image2.Picture = LoadPicture("XYZ")
[/COLOR]
 
Upvote 0
Hi,
I didnt know how to do it from the combobox selection so i did it off the textbox.
If you can advise what i need to do for a combobox selection i will alter it no problem.

The textbox or combobox selection will be made and the 2 different photos will be shown in Image 1 & Image2 both of which will be relevant to the selected item.
The combobox selection prefills the textbox

I will await your reply first regarding go ahead with the textbox or changing it to combobox.

Many Thanks
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,529
Messages
6,114,155
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top