Solved

UserControl - Property Set vursus Property Let?

Posted on 2006-07-07
6
520 Views
Last Modified: 2008-02-26
I am trying to create a OCX and am having trouble with setting the Properties. Can someone explain (with workong examples) the differences between using 'Property Set' and 'Property Let' ?

bdb
0
Comment
Question by:bdbrown
  • 3
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 125 total points
ID: 17058974
Property Set is when you are using an Object as a property (Recordset, Collection, etc.)

Property Let is when you are using a non-object as a property (Integer, Variant, String, etc.)
0
 
LVL 2

Author Comment

by:bdbrown
ID: 17059007
Thanks Jim for the clarification,
So how would I go about setting the background of my control to a different colour at design time and have it stay that colour when I run the app? Would that be a Object or non-Object property?
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17059041
BackColor by itself is often a Long Integer, so that would be Property Let.

Some controls actually have a .Font object property which contains font, size, bold/italic/etc, which would be Property Get.

What control are you using?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 2

Author Comment

by:bdbrown
ID: 17059124
I am creating my own OCX control and want to make avalible some of these format and display properties at design time. When I open the form which the contol is placed, the values that I set at design time reset back to the default settings again. How can I assign default values and still allow the user to set properties at design?
0
 
LVL 22

Assisted Solution

by:danaseaman
danaseaman earned 125 total points
ID: 17063270
Sounds like you are not persisting the new values via PropertyBag  UserControl_ReadProperties and UserControl_WriteProperties. Without this your control will always use the default values or you need to set everything at run-time.

Take adantage of Vb Add-In "ActiveX Control Interface Wizard" which will set all this up correctly.
 
0
 
LVL 2

Author Comment

by:bdbrown
ID: 17081820
Dan; I am going to have to take some time to figure out this properties bag thing but I am sure the answer is in there.

Thanks for the help Jim and Dan - I have increased the points and will split between both of you.

bdb
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now