# Passing enum as parameter (vb.net)



## puneet.darji (Feb 19, 2008)

E.g.

public Enum season
  winter=0
  summer=1  
end enum
public Enum month
  jan=0
  feb=1  
end enum

There are two different enums i want to pass in one common function like.


pubic function fillenum(i send above enum as parameter)

end function

At the time of calling function :-

button_click
   fillenum(season)
   fillenum(month)
end sub


is this posible.

Thnx in adavance


----------



## RCuber (Feb 19, 2008)

^^ you cannot directly pass the enum season or month cause its a type. you have to declare a variable and then passthat to the function

something like this, just a rough example.

```
Public Enum season
        winter = 0
        summer = 1
    End Enum
    Public Enum month
        jan = 0
        feb = 1
    End Enum

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim se As season
        Dim mon As month
        test(se)
        test(mon)
    End Sub

    Sub test(ByRef ses As season)
        MessageBox.Show(ses.summer.ToString & vbCrLf & ses.winter.ToString)
    End Sub

    Sub test(ByRef mo As month)
        MessageBox.Show(mo.feb.ToString & vbCrLf & mo.jan.ToString)
    End Sub
```


----------

