Results 1 to 3 of 3

Thread: [RESOLVED] Select case problem

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Select case problem

    I have added a color chooser to my app, when there is text in a label caption, it should then change its color when its been selected. However, the text is disappearing on me.

    The label is set to transparent but that should not matter at all. This is the select case I am using. Please advise as to what could be missing, and if the select case could be improved... thanks in advance.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     FormBackColor Me
    5. End Sub
    6.  
    7. Private Sub cmdClose_Click()
    8.     Unload Me
    9. End Sub
    10.  
    11. Private Sub pbColor_Click(Index As Integer)
    12.     With frmMain.lblText(m_intControlIndex)
    13.         Select Case pbColor(Index)
    14.             Case 0
    15.                 .ForeColor = &HFFFFFF
    16.                 Unload Me
    17.             Case 1
    18.                 .ForeColor = &HC0C0FF
    19.                 Unload Me
    20.             Case 2
    21.                 .ForeColor = &HC0E0FF
    22.                 Unload Me
    23.             Case 3
    24.                 .ForeColor = &HC0FFFF
    25.                 Unload Me
    26.             Case 4
    27.                 .ForeColor = &HC0FFC0
    28.                 Unload Me
    29.             Case 5
    30.                 .ForeColor = &HFFFFC0
    31.                 Unload Me
    32.             Case 6
    33.                 .ForeColor = &HFFC0C0
    34.                 Unload Me
    35.             Case 7
    36.                 .ForeColor = &HFFC0FF
    37.                 Unload Me
    38.             Case 8
    39.                 .ForeColor = &HE0E0E0
    40.                 Unload Me
    41.             Case 9
    42.                 .ForeColor = &H8080FF
    43.                 Unload Me
    44.             Case 10
    45.                 .ForeColor = &H80C0FF
    46.                 Unload Me
    47.             Case 11
    48.                 .ForeColor = &H80FFFF
    49.                 Unload Me
    50.             Case 12
    51.                 .ForeColor = &H80FF80
    52.                 Unload Me
    53.             Case 13
    54.                 .ForeColor = &HFFFF80
    55.                 Unload Me
    56.             Case 14
    57.                 .ForeColor = &HFF8080
    58.                 Unload Me
    59.             Case 15
    60.                 .ForeColor = &HFF80FF
    61.                 Unload Me
    62.             Case 16
    63.                 .ForeColor = &HC0C0C0
    64.                 Unload Me
    65.             Case 17
    66.                 .ForeColor = &HFF&
    67.                 Unload Me
    68.             Case 18
    69.                 .ForeColor = &H80FF&
    70.                 Unload Me
    71.             Case 19
    72.                 .ForeColor = &HFFFF&
    73.                 Unload Me
    74.             Case 20
    75.                 .ForeColor = &HFF00&
    76.                 Unload Me
    77.             Case 21
    78.                 .ForeColor = &HFFFF00
    79.                 Unload Me
    80.             Case 22
    81.                 .ForeColor = &HFF0000
    82.                 Unload Me
    83.             Case 23
    84.                 .ForeColor = &HFF00FF
    85.                 Unload Me
    86.             Case 24
    87.                 .ForeColor = &H808080
    88.                 Unload Me
    89.             Case 25
    90.                 .ForeColor = &HC0&
    91.                 Unload Me
    92.             Case 26
    93.                 .ForeColor = &H40C0&
    94.                 Unload Me
    95.             Case 27
    96.                 .ForeColor = &HC0C0&
    97.                 Unload Me
    98.             Case 28
    99.                 .ForeColor = &HC000&
    100.                 Unload Me
    101.             Case 29
    102.                 .ForeColor = &HC0C000
    103.                 Unload Me
    104.             Case 30
    105.                 .ForeColor = &HC00000
    106.                 Unload Me
    107.             Case 31
    108.                 .ForeColor = &HC000C0
    109.                 Unload Me
    110.             Case 32
    111.                 .ForeColor = &H404040
    112.             Case 33
    113.                 .ForeColor = &H80&
    114.                 Unload Me
    115.             Case 34
    116.                 .ForeColor = &H4080&
    117.                 Unload Me
    118.             Case 35
    119.                 .ForeColor = &H8080&
    120.                 Unload Me
    121.             Case 36
    122.                 .ForeColor = &H8000&
    123.                 Unload Me
    124.             Case 37
    125.                 .ForeColor = &H808000
    126.                 Unload Me
    127.             Case 38
    128.                 .ForeColor = &H800000
    129.                 Unload Me
    130.             Case 39
    131.                 .ForeColor = &H800080
    132.                 Unload Me
    133.             Case 40
    134.                 .ForeColor = &H0&
    135.                 Unload Me
    136.             Case 41
    137.                 .ForeColor = &H40&
    138.                 Unload Me
    139.             Case 42
    140.                 .ForeColor = &H404080
    141.                 Unload Me
    142.             Case 43
    143.                 .ForeColor = &H4040&
    144.                 Unload Me
    145.             Case 44
    146.                 .ForeColor = &H4000&
    147.                 Unload Me
    148.             Case 45
    149.                 .ForeColor = &H404000
    150.                 Unload Me
    151.             Case 46
    152.                 .ForeColor = &H400000
    153.                 Unload Me
    154.             Case 47
    155.                 .ForeColor = &H400040
    156.                 Unload Me
    157.         End Select
    158.     End With
    159. End Sub

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Select case problem

    what are u using to pick the color? pictureboxes??
    im hoping so... cause if u have 47 pictureboxes in an array and each has the backcolor set to the "color"
    This will save u a lot of coding

    VB Code:
    1. Private Sub Picture1_Click(Index As Integer)
    2.     Label1.ForeColor = Picture1(Index).BackColor
    3. End Sub
    or in your case

    VB Code:
    1. Private Sub pbColor_Click(Index As Integer)
    2.     frmMain.lblText(m_intControlIndex).ForeColor = pbColor(Index).BackColor
    3. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Select case problem

    thanks static, that will definately sort out how to cut down the code (which i am never very good at) and its sorted out the problem of disappearing text. thanks !!
    Quote Originally Posted by Static
    what are u using to pick the color? pictureboxes??
    im hoping so... cause if u have 47 pictureboxes in an array and each has the backcolor set to the "color"
    This will save u a lot of coding

    VB Code:
    1. Private Sub Picture1_Click(Index As Integer)
    2.     Label1.ForeColor = Picture1(Index).BackColor
    3. End Sub
    or in your case

    VB Code:
    1. Private Sub pbColor_Click(Index As Integer)
    2.     frmMain.lblText(m_intControlIndex).ForeColor = pbColor(Index).BackColor
    3. End Sub

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