Yes I am a newb.
I am taking a into to VB 2005 class. Our latest project involves changing the a panel's background image with a button.
I can get the following code to work but only when I have the picture hard pathed to the directory. In runtime it does not find the image when the filename or any combination short of the entire path is listed.
panGraphics.BackgroundImage = Image.FromFile("E:\blah\blah\blah\bin\Debug\Graphics\Picture1.jpg")
panGraphics.BackgroundImage = Image.FromFile("\Picture1.jpg") 'DOES NOT WORK
Then the second part of my question is I want to use this btnChange as a click even to also change the text of a label. But when I try to setup an If statement it will not work.
If panGraphics.BackgroundImage = Image.FromFile(":/Picture1.jpg") Then
panGraphics.BackgroundImage = Image.FromFile("\Picture2.jpg")
lblInformation.text = ("#2")
ElseIf panGraphics.BackgroundImage = Image.FromFile(":/HauntedHouse.jpg") Then
panGraphics.BackgroundImage = Image.FromFile("\HauntedHouse.jpg")
lblInformation.text = ("#1")
End If
I know I am totally off but this is what I got right now and hopefully I can get steered in the right direction.
I am taking a into to VB 2005 class. Our latest project involves changing the a panel's background image with a button.
I can get the following code to work but only when I have the picture hard pathed to the directory. In runtime it does not find the image when the filename or any combination short of the entire path is listed.
panGraphics.BackgroundImage = Image.FromFile("E:\blah\blah\blah\bin\Debug\Graphics\Picture1.jpg")
panGraphics.BackgroundImage = Image.FromFile("\Picture1.jpg") 'DOES NOT WORK
Then the second part of my question is I want to use this btnChange as a click even to also change the text of a label. But when I try to setup an If statement it will not work.
If panGraphics.BackgroundImage = Image.FromFile(":/Picture1.jpg") Then
panGraphics.BackgroundImage = Image.FromFile("\Picture2.jpg")
lblInformation.text = ("#2")
ElseIf panGraphics.BackgroundImage = Image.FromFile(":/HauntedHouse.jpg") Then
panGraphics.BackgroundImage = Image.FromFile("\HauntedHouse.jpg")
lblInformation.text = ("#1")
End If
I know I am totally off but this is what I got right now and hopefully I can get steered in the right direction.