How to add font selector property to User-control in VB6

Adding a property to a user control in VB6 requires 4 subroutines to be filled, the Let/Set, Get and property Bags respectively.

Let and get have the variant as return type as an argument, which means any value can be accessed through the property.

Public Property Get Interval() As Variant

Interval = Timer1.Interval

End Property

Public Property Let Interval(ByVal vNewValue As Variant)

Timer1.Interval = vNewValue

PropertyChanged “Interval”

End Property

Suppose you want to change how do you get the Font Dialog within the Property Window. This can be possible with use of stdfont  in place of Variant as follows

Public Property Set Font(ByVal Nfont As StdFont)

Set lbl_Time.Font = Nfont


PropertyChanged “Font”

End Property

Public Property Get Font() As StdFont

Set Font = UserControl.lbl_Time.Font

End Property

The complete VB6 Stopwatch Project can be accessible in my GitHub repository

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.