devxlogo

React to Font-Changed Events

React to Font-Changed Events

Use WithEvents to perform an action when you change any font properties of a specific control or form. Make sure you set the OLE Automation reference in the References dialog:

 ' Declaration sectionPrivate WithEvents fntAny As StdFontPrivate Sub fntAny_FontChanged(ByVal _	PropertyName As String)	Select Case PropertyName		Case "Name"			' Perform specific action		Case "Size"			' Perform specific action		Case "Italic"			' Perform specific action		Case "Bold"			' Perform specific action		Case "Underline"			' Perform specific action		'...		'...		' Similarly, you can extend the		' functionality for each font property.	End SelectEnd Sub

You only have to assign any form or control’s Font reference to fntAny. For example, if you want to trap the changes in the form’s font attributes, add this code to the Form_Load event:

 Set fntAny = Me.Font' If a control, then Control.Font
See also  5 Benefits of Using Time Tracking Software
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist