Link to home
Create AccountLog in
Avatar of jmsloan
jmsloan

asked on

Type mismatch error

Can someone tell me how I can get this to work.  I am getting a type mismatch error right now.

Public myForeColor As String
myForeColor = "&HFFFF&"

label1.ForeColor = myForeColor
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

this should work better:

System.Drawing.ColorConverter cc = new System.Drawing.ColorConverter();
label1.ForeColor = (System.Drawing.Color) cc.ConvertFromString("#FF0000");
Hi jmsloan;

ForColor is of type Color and not String. The following should do what you want.

        Public myForeColor As Color
        myForeColor = Color.FromArgb(255, 0, 255, 255)
        label1.ForeColor = myForeColor

Fernando
Avatar of Autoeforms
Autoeforms

forecolor is a system drawing color.

try playing with
scColor As New System.Drawing.ColorConverter

and
System.Drawing.ColorTranslator.FromWin32(yourvalue)

greg
Avatar of jmsloan

ASKER

I forgot to mention I am using VB6
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I think this is correct

        Public myForeColor As Long
        '                            RED, GREEN, BLUE  
        myForeColor = RGB(0,   255,      255)
        label1.ForeColor = myForeColor

This value HFFFF is the same as H00FFFF = RED = 0, GREEN = 255,  BLUE = 255