You can do something similar with the extension method.
Imports System.Runtime.CompilerServices Module FontExtensions <Extension()> Public Function ToSize(ByVal OriginalFont As Font, ByVal NewSize As Single) As Font Dim NewFont As Font NewFont = New Font(OriginalFont.FontFamily, NewSize, OriginalFont.Style) Return NewFont End Function End Module
and then call it like this:
SomeObject.Font = Font.ToSize(12)
It still creates the new font backstage, but your application code is not cluttered with the creation process.
source share