Quote Originally Posted by NickThissen View Post
It looks like you wrote that code outside of the designer because there's a "silly" mistake in the param1 declaration that would not have compiled. I assume you mean "ByVal" instead of "dim" there, correct?
Yes, you are right. I wrote this code outside the editor paraphrasing what I had. Just a typo.

Quote Originally Posted by NickThissen View Post
Anyway, the 'error' is that you require param1 to be of type Integer. You should require it to be of type Greeting if you want to pass a Greeting.

An enumeration is just a type like any other. However, enumerations have an 'underlying type' (not sure how to call that) which is an Integer. The first value in your enumeration for example has value 1, and the second has value 2 (you could have used 28 and 982 if you wanted). For this reason, enumerations can be converted to integers (and the other way around too). I think that's the reason that you code compiled in the first place. VB is implicitly converting the Greetings.Hi value to an integer (which is 1 by your enum declaration). If you turn Option Strict On (google it or search this forum) then I think it will not let you compile.

So the only thing you need to change is the TestEnum method signature, to this:
Code:
Private Sub TestEnum(ByVal param1 as Greeting)
Ok, you hit the nail on the head. I think this is the heart of my confusion. The implicit conversion is exactly what I wanted to avoid, I knew that was what was going on since when I change the type from Greeting to Integer I got it to work with the same results. So here is where I am confused. I understand the concept of classes and there members. Doesn't the enum kind of work the same way? Aren't the Hi and Bye like members that have a value assigned to them? I had read and knew about the "underlying" type you mentioned and that was what made me think that the Hi and Bye were Integer values, hence my use of Integer for the type of param1 in the TestEnum method I wrote. This is bizarre to me. I guess I need some sleep or something or I am just retarded

So Greeting is an enum and so is Greeting.Hi and Greeting.bye??