VB.NET function with distinct list as parameter

Harkon

Newcomer
Joined
Jan 4, 2005
Messages
5
Greetings,

I'm not quite sure whether I got it right on the title.
I'd like to make a function say Paint_me and get a colour as parameter.
However I don't want to pass it as an integer (1,2,3..) or string ("blue", "white",...). My ultimate goal is, when the user calls the function and tries to input the colour, a list like that will be presented to him:

vbBlue
vbRed
...

How is this done? Tried something with Structures but didn't manage it to the end.

Thanxs in advance
 
You can use the Color type. When "calling" you get a list like:
Color.Black... etc...

Code:
    Private Sub Paint_me(ByVal TheColor As Color)
        'Drawing code here
    End Sub
 
...or you might want to use enums. This way you can define the list your self.

Code:
    Private Enum ColorEnum
        Black = 1
        White = 2
        Red = 3
    End Enum

    Private Sub Paint_me(ByVal TheColor As ColorEnum)
        Select Case TheColor
            Case ColorEnum.Black
                'Drawing code here
            Case ColorEnum.Red
                'Drawing code here
            Case ColorEnum.White
                'Drawing code here
        End Select
        'Drawing code here
    End Sub
 
Back
Top