|
-
June 26th, 2001, 04:04 PM
#1
It works once and doesn`t work the next time!!!...
Hi all,
I have two images : Image1 and Image2.
I have two buttons : Button1 and Button2.
The code for button1 is this :
Image1.Picture = Image2.Picture.
This changes the images on the click of the button.
The code for button2 is :
Image2.Picture = Image1.Picture.
This does vice versa.
The problem is, if I think click the first button AGAIN to switch back, nothing happens, the same for button2. How can I fix this?
Mark
-
June 26th, 2001, 04:49 PM
#2
Re: It works once and doesn`t work the next time!!!...
It doesn't work because once you change Image1.picture to Image2.picture, then Image1.picture is the same as Image2.picture, so button2 is working, but you see nothing because Image1.picture is now the same as Image2.picture.
There is no longer a different picture for Image2.picture to change to
-
June 26th, 2001, 05:22 PM
#3
Re: It works once and doesn`t work the next time!!!...
Is there any way I can resolve this then?
Mark
-
June 26th, 2001, 05:28 PM
#4
Re: It works once and doesn`t work the next time!!!...
Store the old picture1 to a temporary place, e.g. a hidden picture box, or a variable of type Picture.
-----------------
Visit: http://www.ezoutliner.com
-
June 26th, 2001, 05:53 PM
#5
Re: It works once and doesn`t work the next time!!!...
I made a copy and stored in it a picture box with visible set to False. I checked the original code and ran again, but it still didn`t work - it only changed once.
Mark
-
June 26th, 2001, 10:31 PM
#6
Re: It works once and doesn`t work the next time!!!...
If you want, I can check out your code. Just tell me what process do you intended to do, and I'll see what I can do. Send your code (or a sample form) and your comments to my email: [email protected]
-----------------
Visit: http://www.ezoutliner.com
-
June 27th, 2001, 02:28 AM
#7
Re: It works once and doesn`t work the next time!!!...
Here is an example. You may have to comment two lines to adjust this to your purpouse.
To copy this code: copy and paste to WordPad (not Notepad!).
Then select from WordPad, copy, and paste in VB (Shree suggestion).
option Explicit
Dim oldImg1 as Object
Dim oldImg2 as Object
private Sub Command1_Click()
If Image1.Picture <> Image2.Picture then
Image1.Picture = Image2.Picture
else
Image1.Picture = oldImg1
'do you want the original image2 to be restored too?
'or comment the following line
Image2.Picture = oldImg2
End If
End Sub
private Sub Command2_Click()
If Image1.Picture <> Image2.Picture then
Image2.Picture = Image1.Picture
else
Image2.Picture = oldImg2
'do you want the original image1 to be restored too?
'or comment the following line
Image1.Picture = oldImg1
End If
End Sub
private Sub Form_Load()
set oldImg1 = Image1.Picture
set oldImg2 = Image2.Picture
End Sub
'have fun.
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
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
|