Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Now am doing Picture Box like Button image, I trying to change image when i click on PictureBox3 . By Use IF Condition ,But it not doing. Here my code :

Dim phonestop As Image = My.Resources.phone_exit
   Dim phonestart As Image = My.Resources.phone_start

   Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
       If PictureBox3.Image Is phonestart Then
           PictureBox3.Image = phonestop
       Else
           PictureBox3.Image = phonestart
       End If
   End Sub
Posted

1 solution

The code looks right - so the first thing to do is to follow the code and see what is actually happening.
Put a breakpoint on the first line in the event handler, and single step through, looking at the variables as you go.

Sorry, but with that little info, that's about the best advice I can give at the moment. And remember, I don't have access to your code so I can't run it in situ to check...
 
Share this answer
 
Comments
msymarina 26-Sep-13 11:33am    
You said my code is right !, why it not work ?

Dim phonestop As Image = My.Resources.phone_exit
Dim phonestart As Image = My.Resources.phone_start

Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
If PictureBox3.Image Is phonestart Then
PictureBox3.Image = My.Resources.phone_exit
Else
PictureBox3.Image = My.Resources.phone_start
End If
End Sub
OriginalGriff 26-Sep-13 11:49am    
I said "it looks right" - which means the problem is probably something else.
You need to find out what, and the first stage is to gather information. I can't do that for you, so you need to use the debugger and find out exactly what is going on.
Then you can tell us what you find, and we can move on...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900