|
-
Jun 19th, 2009, 03:17 AM
#1
Thread Starter
Member
[RESOLVED] SavePicture gives 'Invalid use of property'
Hi,
I have a problem saving what is in a PictureBox (PictureBox1) and get the error 'Invalid use of property'
I have Googled it and looked at the code examples. I have looked in the 'VB6 Help'. Everything suggests that my code is OK - but whatever I try I get the same error message!
I am obviously missing something! Can anyone help. My code is below.
Thanks in advance
King Arthur
Private Sub SaveButton_Click()
Dim file_name1 As String
file_name1 = "C:\NF_Data\Graphics\Horiz\PJ1.bmp"
Picture1.AutoRedraw = True
SavePicture Picture1.Image, file_name1
End Sub
-
Jun 19th, 2009, 03:39 AM
#2
-
Jun 19th, 2009, 04:22 AM
#3
Re: SavePicture gives 'Invalid use of property'
i thought you had to pass a picture to the savepicture
vb Code:
picture1.picture = picture1.image savepicture picture1.picture, "C:\test\pic.bmp"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 19th, 2009, 08:33 AM
#4
Thread Starter
Member
Re: SavePicture gives 'Invalid use of property'
Hi,
I tried putting that extra line in before the SavePicture line and I still get the same result.
-
Jun 19th, 2009, 09:02 AM
#5
Re: SavePicture gives 'Invalid use of property'
An obvious question but worth asking: Your 1st post mentioned PictureBox1 but your code uses Picture1. Are you using the correct control name? Is this vb6? If not already done, suggest adding OPTION EXPLICIT to the top of your form.
-
Jun 20th, 2009, 05:52 AM
#6
Thread Starter
Member
Re: SavePicture gives 'Invalid use of property'
Hi there,
I have got the problem sorted.
Thanks for your time and ideas. It was considering your thoughts that guided me to the solution.
As with most programming problems it was something I had done!
I had named a button 'SavePicture'. Stupid I know - but that was why I was getting the properties error when I was trying to save a picture. Once I renamed the button everything worked.
That is what makes programming fascinating - the problem appears in one place but what caused it is somewhere completely different...
Thanks again
King Arthur
-
Jun 20th, 2009, 11:33 AM
#7
Re: [RESOLVED] SavePicture gives 'Invalid use of property'
This is why you should prefix you control names. Had you named your command button cmdSavePicture instead you wouldn't have had the problem and anyone reading the code would have had a pretty good idea what the button was going to do because of it's name.
-
Jun 20th, 2009, 11:43 AM
#8
Thread Starter
Member
Re: [RESOLVED] SavePicture gives 'Invalid use of property'
Yes. I am aware of that... just one of my many bad habits - caught me out this time...
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
|