Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

You can use the Color type. When "calling" you get a list like:

Color.Black... etc...

 

   Private Sub Paint_me(ByVal TheColor As Color)
       'Drawing code here
   End Sub

Posted

...or you might want to use enums. This way you can define the list your self.

 

   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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...