[RESOLVED] about image property in VB6
i have these property:
Code:
Public Property Let Image(ByVal img As Picture)
Set picView.Picture = img
PropertyChanged "Image"
End Property
Public Property Get Image() As Picture
Set Image = picView.Image
End Property
these property is working i need put it in UC properties events:
Code:
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Image", Image, Null
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Image = PropBag.ReadProperty("Image", "")
End Sub
but i recive 1 error in:
Code:
Image = PropBag.ReadProperty("Image", "")
error message: "Run-Time error '424': Object Required"
why these error, can anyone help me resolve these error?
thanks
Re: about image property in VB6
Don't use Null, use Nothing in the Write. And in the Read, don't use "", use Nothing. Also don't forget to use the key word Set.
Code:
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Image", picView.Image, Nothing
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set picView.Image = PropBag.ReadProperty("Image", Nothing)
End Sub
Re: about image property in VB6
Quote:
Originally Posted by LaVolpe
Don't use Null, use Nothing in the Write. And in the Read, don't use "", use Nothing. Also don't forget to use the key word Set.
Code:
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Image", picView.Image, Nothing
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set picView.Image = PropBag.ReadProperty("Image", Nothing)
End Sub
thanks but both(us) have 1 error, that i found and resolved:
Code:
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Image", picView.Image, Nothing
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set picView.Picture = PropBag.ReadProperty("Image", Nothing) 'it's picture and not image, like i was thinking
End Sub
thanks
Re: [RESOLVED] about image property in VB6
Good catch. Though you should probably change the .Image to .Picture also in the .WriteProperty line.
Re: [RESOLVED] about image property in VB6
Quote:
Originally Posted by LaVolpe
Good catch. Though you should probably change the .Image to .Picture also in the .WriteProperty line.
Code:
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Image", picView.Image, Nothing
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
picView.Picture = PropBag.ReadProperty("Image", Nothing)
End Sub
Public Property Let Image(ByVal img As Picture)
Set picView.Picture = img
PropertyChanged "Image"
End Property
Public Property Get Image() As Picture
Set Image = picView.Image
End Property
i'm sorry, but i think not. because the Image is read-only and the picture is write-only.(tell me if i'm not right).
thanks
Re: [RESOLVED] about image property in VB6
i'm sorry, but i found 1 problem in these property.
when i do these:
Code:
Form1.Picture = LevelEditor2D1.Image
works fine. but when i do these:
Code:
LevelEditor2D1.Image=form1.image
i recive 1 error:
"run-time '450': wrong number of arguments or invalid property asignmant"
what isn't right?
i'm sorry and thanks
Re: [RESOLVED] about image property in VB6
> PropBag.WriteProperty "Image", picView.Picture, Nothing < should not generate any error if there is a picture property.
Regarding your runtime 450 error. Change your property parameters to stdPicture vs Picture
Tip, when I code a property to receive a stdPicture or stdFont object, I usually use 3 property statements. This way if the user included the keyword SET or not, no 450 error is generated.
Example:
Code:
Public Property Let Image(ByVal theImage As stdPicture)
Set Image = theImage
End Property
Public Property Set Image(ByVal theImage As stdPicture)
Set picView.Picture = theImage
End Property
Public Property Get Image() As stdPicture
Set Image = picView.Picture
End Property
Re: [RESOLVED] about image property in VB6
Quote:
Originally Posted by LaVolpe
> PropBag.WriteProperty "Image", picView.
Picture, Nothing < should not generate any error if there is a picture property.
Regarding your runtime 450 error. Change your property parameters to
stdPicture vs Picture
Tip, when I code a property to receive a stdPicture or stdFont object, I usually use 3 property statements. This way if the user included the keyword SET or not, no 450 error is generated.
Example:
Code:
Public Property Let Image(ByVal theImage As stdPicture)
Set Image = theImage
End Property
Public Property Set Image(ByVal theImage As stdPicture)
Set picView.Picture = theImage
End Property
Public Property Get Image() As stdPicture
Set Image = picView.Picture
End Property
it's working thanks. i'm sorry but can o give me how you do the font property. in here my problem is these property has some subproperties(fontname, fontsize and others). thank you very much
Re: [RESOLVED] about image property in VB6
For a complete font, just change stdPicture to stdFont.
For the individual FontName, FontSize, etc. You have to supply separate Get/Let properties for each of those. Sorry.
Re: [RESOLVED] about image property in VB6
Quote:
Originally Posted by LaVolpe
For a complete font, just change stdPicture to stdFont.
For the individual FontName, FontSize, etc. You have to supply separate Get/Let properties for each of those. Sorry.
i understand, but i need ask you something:
for example: a have fontname and fontsize properties. and the font property.
has you know the font property has very subproperties, and these subproperties values can be used for change the fontsize and fontname,right?
and for these i use the SET property or other?
thanks
Re: [RESOLVED] about image property in VB6
No, use Let. Set is used for Objects.
Set myFont = [font object] << Set
myFont.FontBold = True << Let
Re: [RESOLVED] about image property in VB6
Quote:
Originally Posted by LaVolpe
No, use Let. Set is used for Objects.
Set myFont = [font object] << Set
myFont.FontBold = True << Let
thanks my friend.... thank you