Results 1 to 6 of 6

Thread: ActiveX BackColor/ForeColor Properties

  1. #1

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    ActiveX BackColor/ForeColor Properties

    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°°»

    Visual Studio 6, Visual Studio.NET 2005, MASM

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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:
    VB Code:
    1. Public Property Get BackColor() As OLE_COLOR
    2.    BackColor = UserControl.Label.BackColor
    3. End Property
    4.  
    5. Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
    6.    Label.BackColor = New_BackColor
    7.    PropertyChanged ("BackColor")
    8. End Property
    Last edited by Edneeis; Jun 21st, 2002 at 10:04 AM.

  3. #3

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Thanks Edneeis, i got that. If you could, Explain Let Get and Set differences?? WHat i use each one for. Thanks heaps,



    «°°phReAk°°»

    Visual Studio 6, Visual Studio.NET 2005, MASM

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Thanks alot Edinees, youve helped heaps, now i understand it all.



    «°°phReAk°°»

    Visual Studio 6, Visual Studio.NET 2005, MASM

  6. #6
    New Member
    Join Date
    Jun 2002
    Location
    US
    Posts
    1

    Exclamation

    Use "Set" when working with objects, not properties... hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width