Results 1 to 14 of 14

Thread: A little confused about Enumerations

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member The Fire Snake's Avatar
    Join Date
    Sep 2009
    Location
    USA
    Posts
    401

    Re: A little confused about Enumerations

    Quote Originally Posted by NickThissen View Post
    Another thing. What are you expecting the output of the TestEnum message box to be? If you expect "param1" to show "param1 = 1" then you should keep using what you have now. If you expect it to be "param1 = Hi" however you should use the ToString function:
    Code:
    Private Sub TestEnum(ByVal param1 as Greeting)
       Msgbox("param1 = " & param1.ToString())
    End Sub
    I was expecting the output of the message box to be "param1 = 1". Thanks for the info on the ToString method in regards to enums. That can certainly come in handy.

  2. #2
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: A little confused about Enumerations

    Quote Originally Posted by The Fire Snake View Post
    I was expecting the output of the message box to be "param1 = 1". Thanks for the info on the ToString method in regards to enums. That can certainly come in handy.
    Well in that case what you were doing was technically correct (with option strict off), but still I wouldn't recommend it. With option strict on by the way you should have made the call differently, like so:
    Code:
    TestEnum(CInt(Greetings.Hi))
    But if you do that, you loose all the advantages of having an enum in the first place! You could just as well use in integer in that case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width