?
Solved

Type mismatch error

Posted on 2007-10-08
7
Medium Priority
?
239 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:jmsloan
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20036355
this should work better:

System.Drawing.ColorConverter cc = new System.Drawing.ColorConverter();
label1.ForeColor = (System.Drawing.Color) cc.ConvertFromString("#FF0000");
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 20036369
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
 
LVL 8

Expert Comment

by:Autoeforms
ID: 20036377
forecolor is a system drawing color.

try playing with
scColor As New System.Drawing.ColorConverter

and
System.Drawing.ColorTranslator.FromWin32(yourvalue)

greg
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:jmsloan
ID: 20036440
I forgot to mention I am using VB6
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 20036476
with vb6, just do it like this:
label1.ForeColor = val(myForeColor)
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 20036541
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question