Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing pictures in a picture box...

Status
Not open for further replies.

ironmunk

Technical User
Aug 21, 2001
51
CA
What is the code to change a picture in a picture box?

I've tried

Picture1.picture = "Picture.jpg"

That does'nt work.

Help.
 
from MSDN:

Picture Property Example
This example loads icons from the Visual Basic icon library into two of three PictureBox controls. When you click the form, the third PictureBox is used to switch the icons. You can use any two icons. Paste the code into the Declarations section of a form that has three small PictureBox controls (for Picture3, set Visible = False). Press F5 to run the program, and then click the form.

Private Sub Form_Load ()
' Load the icons.
Picture1.Picture = LoadPicture("ICONS\COMPUTER\TRASH02A.ICO")
Picture2.Picture = LoadPicture("ICONS\COMPUTER\TRASH02B.ICO")
End Sub

Private Sub Form_Click ()
' Switch the icons.
Picture3.Picture = Picture1.Picture
Picture1.Picture = Picture2.Picture
Picture2.Picture = Picture3.Picture
' Clear the third picture (not necessary if not visible).
Picture3.Picture = LoadPicture()
End Sub

This example pastes a bitmap from the Clipboard into a PictureBox control. To find the value of Clipboard format constants (starting with vbCF), see the Visual Basic (VB) object library in the Object Browser. To try this example, paste the code into the Declarations section of a form that has a PictureBox control. Press F5, and then in another application, copy an icon onto the Clipboard, switch to Visual Basic, and click the form.

Private Sub Form_Click ()
Picture1.Picture = Clipboard.GetData(vbCFDIB)
End Sub


--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top