Solved

ActiceX and Not Remember Properties

Posted on 2004-08-26
3
180 Views
Last Modified: 2013-11-26
Hi,

I have created and activex object that has a property for the path of a file. My problem is that when i put a path in the corresonse property spot then do something else in the project. when i come back the value is not there.

Am i going crazy or is this a problem?

Please help
0
Comment
Question by:cossy74
  • 2
3 Comments
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 11910217
Hi,

Have you played with UserControl_ReadProperties event and UserControl_WriteProperties event of the user control (Your activeX).

Cheers!
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11910709
Try this method:

'------------------------------------------------------
Dim myPath As String                          'internal variable with which the control works with

Public Property Get Path() As String
    Path = myPath                                'when someone from outside wants to get the value of Path property, pass it the value from internal variable
End Property

Public Property Let Path(ByVal vNewValue As String)
    myPath = vNewValue                                                 'when something from the outside changes the property, forward the value to internal variable and...
    PropertyChanged "Path"                                             'report to visual basic that property was changed, so it can update the value in property list
End Property

Private Sub UserControl_InitProperties()
    myPath = "c:\"                                               'when control is first created, assign the default value to the property
    PropertyChanged "Path"
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "Path", myPath, "c:\"                                'when control is destroyed, (for example, you close the form), save the property value in the PropertyBag
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    myPath = PropBag.ReadProperty("Path", "c:\")                            'when the control is recreated (the form is oppened again), read the value from the PropertyBag
    PropertyChanged "Path"
End Sub
'--------------------------------------------------------------------------------

0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 500 total points
ID: 11910735
Read this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconcreatingactivexcontrol.asp

and especially "Life and Times of a UserControl Object"     ->     http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconlifetimesofusercontrol.asp

It will explain why you have to save properties and read them so often.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 63
MsgBox 2 47
Put text in a picture ASP.NET C# 2 50
SQL VB connection works in one PC and doesn't in another 15 55
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

932 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

11 Experts available now in Live!

Get 1:1 Help Now