Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Properties in ActiveX Controls
Message
General information
Forum:
Visual Basic
Category:
ActiveX controls
Miscellaneous
Thread ID:
00820165
Message ID:
00820194
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
Use the PropBag in the UserControl read and write properties event. I can't remember the exact name off of the top of my head of the events but they are pretty easy to determine.

Use use the read and write methods of the propbag to load and save your design time edited values.



>Hi!
>
>I have a property for a user-defined control,
>
>In design mode of a Form I insert my Control and modify the property, and I can see the changes, but, when I execute the form, the property initializes.
>
>The question would be: How to preserve the value of a property that has been changed in design mode?
>
>Here's the code for the user control:
>
>
>Option Explicit
>
>Dim cDateFormat(3) As String
>Private nDateFormat As DateFormat_Enum
>
>Enum DateFormat_Enum
>    YMD_Format = 1
>    MDY_Format = 2
>    DMY_Format = 3
>End Enum
>
>Public Property Get DateFormat() As DateFormat_Enum
>    DateFormat = nDateFormat
>End Property
>
>Public Property Let DateFormat(pDateFormat As DateFormat_Enum)
>    If nDateFormat <> pDateFormat Then
>        With txtDate
>            .Text = ChangeDateFormat(.Text, cDateFormat(nDateFormat), cDateFormat(pDateFormat))
>        End With
>        nDateFormat = pDateFormat
>    End If
>End Property
>
>Function ChangeDateFormat(ByVal sDate As String _
>, ByVal cOldFormat As String, ByVal cNewFormat As String) As String
>
>    Dim nY As Integer
>    Dim nM As Integer
>    Dim nD As Integer
>
>    Dim cY As String
>    Dim cM As String
>    Dim cD As String
>
>    Dim cS As String
>    Dim cR As String
>
>    cS = LCase(cOldFormat)
>    cR = LCase(cNewFormat)
>
>    nY = InStr(1, cS, "yyyy")
>    nM = InStr(1, cS, "mm")
>    nD = InStr(1, cS, "dd")
>
>    cY = Mid(sDate, nY, 4)
>    cM = Mid(sDate, nM, 2)
>    cD = Mid(sDate, nD, 2)
>
>    cR = Replace(cR, "yyyy", cY)
>    cR = Replace(cR, "mm", cM)
>    cR = Replace(cR, "dd", cD)
>
>    ChangeDateFormat = cR
>
>End Function
>
>Sub InitDateFormat()
>
>    cDateFormat(1) = "yyyy/MM/dd"
>    cDateFormat(2) = "MM/dd/yyyy"
>    cDateFormat(3) = "dd/MM/yyyy"
>
>    ' begin. comment.
>    ' Without this code, the format will explode
>    ' because the element 0 of the array is empty
>    If nDateFormat = 0 Then
>        nDateFormat = YMD_Format
>    End If
>    ' end. comment.
>
>End Sub
>
>Private Sub UserControl_Initialize()
>    InitDateFormat
>End Sub
>
>
>Any help would by appreciated
>
>thanks in advance!
Brian Seekford
Seekford Solutions, Inc.
http://www.SeekfordSolutions.com
Internet ActiveX Controls and .NET Class Libraries.
SMTP/S FTP POP3/S HTTP/S SNTP MIME PING WHOIS TRACEROUTE NNTP DNS MX
Base64, UUEncode, yEnc, MD5, SHA1, URL, Quoted-Printable.
Resizer and Tooltips
Email Verification and more. Check us out!
Previous
Reply
Map
View

Click here to load this message in the networking platform