The following code was inspired and co-written by FourBlades.

The following method will take any combined enumerated value and return an array containing the constituent parts. It is intended to be used with enumerated types that have the Flags attribute applied, allowing you to combine multiple values into a single value, where each bit of the composite value represents one of the flags. An example of such a type is the FontStyle enumeration.
VB.NET Code:
  1. Public Function GetConstituentFlags(Of T)(ByVal value As T) As T()
  2.     Dim genericType As Type = GetType(T)
  3.  
  4.     If Not genericType.IsEnum Then
  5.         Throw New ArgumentException("Generic argument type must be an enumerated type.")
  6.     End If
  7.  
  8.     Dim numericValue As Integer = Convert.ToInt32(value)
  9.     Dim flags As New List(Of T)
  10.  
  11.     If numericValue = 0 Then
  12.         If [Enum].IsDefined(genericType, 0) Then
  13.             flags.Add(DirectCast([Enum].ToObject(genericType, 0), T))
  14.         End If
  15.     Else
  16.         For Each constant As Integer In [Enum].GetValues(genericType)
  17.             If constant <> 0 AndAlso (numericValue And constant) = constant Then
  18.                 flags.Add(DirectCast([Enum].ToObject(genericType, constant), T))
  19.             End If
  20.         Next constant
  21.     End If
  22.  
  23.     Return flags.ToArray()
  24. End Function
This is a good example of a generic function. Many people will only be familiar with generics in relation to collections. If you want to see it in action, try editing the Bold, Italic, Underline and Strikethrough properties of a form's Font property and running the project with this code:
VB.NET Code:
  1. Private Sub Form1_Load(ByVal sender As Object, _
  2.                        ByVal e As EventArgs) Handles MyBase.Load
  3.     For Each style As FontStyle In Me.GetConstituentFlags(Me.Font.Style)
  4.         MessageBox.Show(style.ToString())
  5.     Next style
  6. End Sub
Note that if you don't apply any styles to the font the method automatically returns the zero value for that enumeration, which is Regular. I haven't specifically tested it but this method should also support negative values.