Blake81
Well-known member
I have about 100 JPG files to use as weather icons, and I want to put them in the resources to get away from having to navigate to a file path to get them. On my forecast page, I finally got it all working, so I tried to change the line where it gets the icon from a file path to My.Resources.GetObject like JohnH showed me. It works from the file path, but not from the resources. Why is this? Here's the code. I'll leave it so that Day 1 tries to get it from My.Resources, and Day 2 gets it from a file path so you can see the difference.
[/SIZE]
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Day1IconLoc [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2]Day1IconLoc = [/SIZE][SIZE=2][COLOR=#800000]"a"[/COLOR][/SIZE][SIZE=2] & xmldocument.SelectSingleNode([/SIZE][SIZE=2][COLOR=#800000]"/weather/dayf/day[@d='1']/part[@p='d']/icon"[/COLOR][/SIZE][SIZE=2]).InnerText
Day1Pic.Image = [/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Resources.ResourceManager.GetObject(Day1IconLoc)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Day2IconLoc [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2]Day2IconLoc = [/SIZE][SIZE=2][COLOR=#800000]"a"[/COLOR][/SIZE][SIZE=2] & xmldocument.SelectSingleNode([/SIZE][SIZE=2][COLOR=#800000]"/weather/dayf/day[@d='2']/part[@p='d']/icon"[/COLOR][/SIZE][SIZE=2]).InnerText & [/SIZE][SIZE=2][COLOR=#800000]".jpg"
[/COLOR][/SIZE][SIZE=2]Day2Pic.Image = Image.FromFile([/SIZE][SIZE=2][COLOR=#800000]"C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\X-Weather1\X-Weather1\test\"[/COLOR][/SIZE][SIZE=2] & Day2IconLoc)[/SIZE]
[SIZE=2]