-
Feb 8th, 2018, 03:53 AM
#1
Thread Starter
Junior Member
How to change image when it click repeatedly
HELLO
I wont when I click the image it changes the image
when I click the image again it well return to original image.
I'm using this code but it changed one time.
Private Sub Image1_Change()
Image4.Picture = LoadPicture("C:\Users\pc1\Desktop\Projectsone\Untitled.jpg")
-
Feb 8th, 2018, 06:33 AM
#2
Re: How to change image when it click repeatedly
You'll need a value to use as a flag to indicate the state of the image, i.e. which image is showing.
Typically this would be a Boolean value which can toggle between True and False, but you might want to use the Tag property of the control so you don't have to maintain a flag somewhere that is external to the control.
The code might look like this.
Code:
Private Sub Image1_Change()
If Image4.Tag = "B" Then
Image4.Tag = "A"
Image4.Picture = LoadPicture("C:\Users\pc1\Desktop\Projectsone\Untitled.jpg")
Else
Image4.Tag = "B"
Image4.Picture = LoadPicture("C:\Users\pc1\Desktop\Projectsone\Titled.jpg")
End If
End Sub
Note that the code you posted didn't seem to correlate with what you said you needed, and my code was based on your code.
The assumption being that when you click on something, you get an Image1_Change event, which is toggling the picture in Image4.
If you really want to click on the image to toggle the image, change the event to the click event of the image control instead of the Changed event of a different image control.
Last edited by passel; Feb 8th, 2018 at 06:43 AM.
-
Feb 8th, 2018, 05:28 PM
#3
Re: How to change image when it click repeatedly
So, OP, what you are saying is you only have TWO images---an original, and another. Is that correct?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|