This example draws a circle in the first PictureBox control each time you click it. When you click the second PictureBox, the graphic from the first PictureBox is copied into it. To try this example, paste the code into the Declarations section of a form that has two large, equal-sized PictureBox controls. Press F5 to run the program, and then click the PictureBox controls.
Private Sub Form_Load ()
' Set AutoRedraw to True.
Picture1.AutoReDraw = True
End Sub
Private Sub Picture1_Click ()
' Declare variables.
Dim PW, PH
' Set FillStyle to Solid.
Picture1.FillStyle = vbFSSolid
' Choose random color.
Picture1.FillColor = QBColor(Int(Rnd * 15))
PW = Picture1.ScaleWidth ' Set ScaleWidth.
PH = Picture1.ScaleHeight ' Set ScaleHeight.
' Draw a circle in random location.
Picture1.Circle (Int(Rnd * PW), Int(Rnd * PH)), 250
End Sub
Private Sub Picture2_Click ()
' Copy Image to Picture2.
Picture2.Picture = Picture1.Image
End Sub