Harkon Posted March 1, 2008 Posted March 1, 2008 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 Quote
JumpyNET Posted March 2, 2008 Posted March 2, 2008 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 Quote
JumpyNET Posted March 2, 2008 Posted March 2, 2008 ...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 Quote
Harkon Posted March 3, 2008 Author Posted March 3, 2008 Yes, the Enum is what I was looking for! thank you very much! :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.