|
-
Feb 24th, 2012, 11:33 AM
#1
Thread Starter
Addicted Member
why do I have this error?
I just did
Public This as new bitmap = picturebox1.image and then this error showed up
System.InvalidOperationException but it had nothing to do with that form, why is this?
Thank you
-
Feb 24th, 2012, 11:51 AM
#2
Re: why do I have this error?
vb Code:
Public Class Form1
Public This As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
This = DirectCast(PictureBox1.Image, Bitmap)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 24th, 2012, 11:54 AM
#3
Thread Starter
Addicted Member
Re: why do I have this error?
thanks but now I got another error.
This: picturbox2.Image = This
gives this error: ArgumentException was unhandled Invalid parameter
Thanks
-
Feb 24th, 2012, 11:57 AM
#4
Re: why do I have this error?
works for me:
vb Code:
Public Class Form1
Public This As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
This = DirectCast(PictureBox1.Image, Bitmap)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox2.Image = This
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 24th, 2012, 11:57 AM
#5
Re: why do I have this error?
I would stay away from the word 'this' on the principle of the thing. It shouldn't have any meaning in VB, but it is the same as Me in C languages.
My usual boring signature: Nothing
 
-
Feb 24th, 2012, 12:04 PM
#6
Thread Starter
Addicted Member
Re: why do I have this error?
but how can I stop getting that error?
-
Feb 24th, 2012, 12:16 PM
#7
Re: why do I have this error?
you''ll need to show us the relevant code
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 24th, 2012, 03:31 PM
#8
Re: why do I have this error?
by paying attention to what you're doing... an IMAGE object is NOT A BITMAP... that's why there is a DIRECTCAST in the code Paul posted... seriously Paul, would it KILL you to post an explanation for the code you share once in a while? It doesn't do much good when they can't follow what's going on... anyways...
Since an Image is not a Bitmap, you can't simply assign one to the other... you have to cast or convert it somehow... in both directions. So if you have to use DirectCast to take an .Image and put it into a Bitmap object, doesn't it stand to reason that you would have to use DirectCast to take a Bitmap and put it into an .Image?
-tg
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
|