PDA

Click to See Complete Forum and Search --> : ActiveX BackColor/ForeColor Properties


chemicalNova
Jun 21st, 2002, 05:50 AM
Hello all,

Im just starting ActiveX Programming and i was wondering how to make a BackColor and ForeColor Property for the "Label" Type Control. Ive Got Font fine, but BackColor isnt working. Ive tried;



Public Property Get BackColor() As OLE_COLOR
Set BackColor = UserControl.Label.BackColor
End Property

Public Property Set BackColor(ByVal New_BackColor As OLE_COLOR)
Set Label.BackColor = New_BackColor
PropertyChanged ("BackColor")
End Property

Get and Object Required Error but it is highlighting BackColor in the Property Get sub.


Help


«°°phReAk°°»

Edneeis
Jun 21st, 2002, 10:00 AM
The Backcolor property isn't an object so you can't use set, both inside the sub and use Let instead of Set in the declare section. Like this:

Public Property Get BackColor() As OLE_COLOR
BackColor = UserControl.Label.BackColor
End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
Label.BackColor = New_BackColor
PropertyChanged ("BackColor")
End Property

chemicalNova
Jun 21st, 2002, 10:31 AM
Thanks Edneeis, i got that. If you could, Explain Let Get and Set differences?? WHat i use each one for. Thanks heaps,



«°°phReAk°°»

Edneeis
Jun 21st, 2002, 10:46 AM
Sure, GET is used when your property data is being retrieved FROM your property (i.e. anytime you use x=MyProperty).
LET is used when data is being assigned TO your property (i.e. MyProperty=x) and SET is used with or in place of LET but only when you are dealing with Objects (i.e. Set myProperty=x). So if the property is an object like StdPicture, TextBox, Class Module... then you use Set otherwise you use Let.

chemicalNova
Jun 24th, 2002, 05:38 AM
Thanks alot Edinees, youve helped heaps, now i understand it all.



«°°phReAk°°»

g60
Jun 26th, 2002, 09:16 PM
Use "Set" when working with objects, not properties... hth