Results 1 to 8 of 8

Thread: VB6 - how can i create my own color enum?

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    VB6 - how can i create my own color enum?

    how can i create my own color enum?
    Code:
    Private Enum WallColor
        color1 = vbRed
        color2 = vbBlue
    End Enum
    Code:
    'sample
    dim s as WallColor
    s=0
    the 's' must be red, but it's black
    so how can i change my enum for get these results?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: VB6 - how can i create my own color enum?

    Code:
    Dim s As WallColor
    s = color1
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - how can i create my own color enum?

    i know that... but i need an integer value from a variable value...
    Code:
    s=wall[4] 'wall' it's an integer array.. true between 0 and 3 in these case
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,730

    Re: VB6 - how can i create my own color enum?

    just create a function

    function WallColor&(Byval Id&)
    select case id
    case 0: WallColor = vbRed
    End select
    end function

    s = wallcolor(0)

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: VB6 - how can i create my own color enum?

    Or initialize a cross-reference array, where the array's item values are the colors, and the array's index values are your numbers.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,730

    Re: VB6 - how can i create my own color enum?

    in my game I do all that in my "builder-tool" so I do all the needed initalizations and that is saved to a file.
    the main game will load that, so everything is prepared.
    its both for in-game strings/numbers etc and the editor-pool, for all kinds of information.
    as well as all items, maps etc.

  7. #7

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - how can i create my own color enum?

    Quote Originally Posted by Elroy View Post
    Or initialize a cross-reference array, where the array's item values are the colors, and the array's index values are your numbers.
    i love your idea\sugestion.. thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 - how can i create my own color enum?

    A color palette array seems like a good option if you use a set of colors by index value. But unless it must be variable I'm not sure how it is better than using enumerated constants.

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