[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
Re: SavePicture gives 'Invalid use of property'
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"
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.
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.
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
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.
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... :wave: