I'm coding in VB6.

I have pictures in Picture1 and Picture2.
I would like to replace the picture in Picture1 with the picture in Picture2.

What code will get this done?

Thanks.

Recommended Answers

All 3 Replies

i think there are two way, hope one help you.
1-

Dim img as string
img = "c:\100.bmp"
picStatus.Picture = LoadPicture(img)

2- give the file name directly
picStatus.Picture "C\:100.bmp"

What worked for me: I created a form with 2 pictures and a command button. I loaded an image in Picture2 during design-time and left Picture1 empty. I then used this VB6 function to copy the image when I clicked the command button that I called cmdCopy.

Sub cmdCopy_Click()
    Set Picture1.Picture = Picture2.Picture
End Sub

You can then change Picture2's Picture property and leave Picture1 unaffected.

You can use Picture1.Picture = Picture2.Picture or Picture1.Picture = Picture2.Image to transfer picture from one picture control to another.
The Image property transfers entire edited picture (if you did any editing in picture2 over the original picture) from picture2 to picture1 but the Picture property transfer only the original one not the editing portion/ edited picture.

Hope it can help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.