Ok, C# and .Net have features that people from the VBA world can only … dream about. In a way. I was recently taking a look at the Type.GetEnumNames() function in .Net and I simply thought that it would be useful somehow to have it in VBA as well.
Thus, if you have ever wondered how the magic of printing the enum values looks like, you may do it by yourself with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
using System; class EnumsExampleZ { private enum SiteNames { VitoshAcademy = 1, VitConsulting = 2, SomeOtherSite = 3 } static void Main() { Type enumType = typeof(SiteNames); string[] enumName = enumType.GetEnumNames(); for (int i = 0; i < enumName.Length; i++) { Console.WriteLine(enumName[i]); } } } |
That should be enough! 🙂