Picture box
Picture box
Picture box
Picture box
Picture box
Picture box Picture box Picture box Picture box Picture box Picture box Picture box Picture box
Picture box Picture box
Picture box
Go Back  Xtreme Visual Basic Talk > > > Picture box


Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2012, 04:12 PM
husbancom husbancom is offline
Newcomer
 
Join Date: Jun 2012
Posts: 1
Default Picture box


Hi guys

I am all new to Visual Basic 2008, I am trying to create a picture shuffle game, the problem is I cant seem to be able to move one picture from PictureBox1 to PictureBox2 onClick, here is a Code I written earlier:

Sub ChangePicture(ByRef P1 As PictureBox, ByRef P2 As PictureBox)
If P2.Image Is Nothing Then
P1.BackgroundImage = Nothing
P2.Image = P1.Image
P1.Image.Dispose()
P1.Image = Nothing
End If
End Sub

Problem now there is an X in the middle of PictureBox2.
any ideas why this is happenning, I reckon it may be somethingto do with tranperancy if not mistaken.

any help is highly appreciated
Reply With Quote
  #2  
Old 06-04-2012, 05:49 PM
PlausiblyDamp's Avatar
PlausiblyDampPicture box PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Try removing the line
Code:
P1.Image.Dispose()
when you do
Code:
P2.Image = P1.Image
you aren't copying an image from one picturebox to another, you are simply making both pictureboxes get their image from the same location in memory. When you then tell the system to dispose of the image you are effectively disposing of the image that both pictureboxes are trying to use.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Picture box
Picture box
Picture box Picture box
Picture box
Picture box
Picture box Picture box Picture box Picture box Picture box Picture box Picture box
Picture box
Picture box
 
Picture box
Picture box
 
-->