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
LVL 3
jmsloanAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
with vb6, just do it like this:
label1.ForeColor = val(myForeColor)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this should work better:

System.Drawing.ColorConverter cc = new System.Drawing.ColorConverter();
label1.ForeColor = (System.Drawing.Color) cc.ConvertFromString("#FF0000");
0
 
Fernando SotoRetiredCommented:
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
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
AutoeformsCommented:
forecolor is a system drawing color.

try playing with
scColor As New System.Drawing.ColorConverter

and
System.Drawing.ColorTranslator.FromWin32(yourvalue)

greg
0
 
jmsloanAuthor Commented:
I forgot to mention I am using VB6
0
 
Fernando SotoRetiredCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.