Results 1 to 3 of 3

Thread: [RESOLVED] Correct values to use to change form forcolor

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    184

    Resolved [RESOLVED] Correct values to use to change form forcolor

    Hi. I have the code below where I'm trying to change the forcolor of text but the compiler is telling me that integer cannot be converted to color. I tried RGB(xxx,xxx,xxx) but got the same results.
    What is the correct answer to change the text forcolor? This code is being ported from VBA. I have both and ENUM version and a Hex version, and neither seem to work. Please advise.

    Code:
            If (InStr(szResult, "Yes") <> 0) Then
                RISK_REPORTABLE_TXT.ForeColor = ENUM_CTRL_COLOR.eCOLOR_TXT_RED
                FRM_RISK.ForeColor = RGB(255, 0, 0) '&HFF&
                FRM_RISK.Enabled = True
                RISK_REPORTABLE_TXT.Enabled = True
            Else
                RISK_REPORTABLE_TXT.ForeColor = ENUM_CTRL_COLOR.eCOLOR_TXT_BLACK
                FRM_RISK.ForeColor = RGB(255, 255, 255)    '&H80000012
                FRM_RISK.Enabled = False
                RISK_REPORTABLE_TXT.Enabled = False
            End If

  2. #2
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    770

    Re: Correct values to use to change form forcolor

    To set forecolor to yellow:

    FRM_RISK.ForeColor = Color.FromArgb(255, 255, 255, 0)

    The first value is the "alpha" channel. 255 is fully opaque.

    You can also use:

    FRM_RISK.ForeColor = Color.Yellow

    Intellisense will show you the large number of "preset" colors available.
    Last edited by paulg4ije; Mar 20th, 2025 at 04:02 PM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    184

    Re: Correct values to use to change form forcolor

    Thanks!

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