Combining Enums

I believe what you want is a flag type enum.

You need to add the Flags attribute to the top of the enum, and then you can combine enums with the ‘Or’ keyword.

Like this:

<Flags()> _
Enum CombinationEnums As Integer
  HasButton = 1
  TitleBar = 2
  [ReadOnly] = 4
  ETC = 8
End Enum

Note: The numbers to the right are always twice as big (powers of 2) – this is needed to be able to separate the individual flags that have been set.

Combine the desired flags using the Or keyword:

Dim settings As CombinationEnums
settings = CombinationEnums.TitleBar Or CombinationEnums.Readonly

This sets TitleBar and Readonly into the enum

To check what’s been set:

If (settings And CombinationEnums.TitleBar) = CombinationEnums.TitleBar Then
  Window.TitleBar = True
End If

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)