?
Solved

HTML color code

Posted on 1998-07-03
3
Medium Priority
?
356 Views
Last Modified: 2012-06-21
How can I convert my Visual Basic color code into HTML color code?
Using the HEX function doesn't always get the colors that I chose.
Does anyone know how to get the correct colors?
0
Comment
Question by:captain_needa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1464909
Are you using the VB default colors???

Can u provide further details on your application

0
 

Expert Comment

by:xlunax
ID: 1464910
I dont even know if VB uses the same HEX codes as HTML at all.  They may be incompatible with each other.  What you may need to do is write a database with as many colors as you know the HTML HEX string for and have VB search it for what you are looking for.  Unfortunatly that will be VERY LARGE.  =)
0
 
LVL 6

Accepted Solution

by:
alamo earned 300 total points
ID: 1464911
There are 3 possible reasons:

Most significantly, VB's color colde and HTML's color code is different. In VB ff0000 is blue and in html it's red, whereas in VB 0000ff is red and in html it's blue. Green is the same in both.

Secondly, VB can use Windows system colors. A system color is a color like &H80000001 where VB looks up the color settings on the particular machine in use.

Finally - browsers sometimes can't display the exact color shade a page has, so it does its best. This is most often true on displays with limited colors. There is nothing you can do about this except try to choose colors which will still look good if they aren't quite right. (And choose colors which almost all displays can handle).

The following function will convert a VB color code to the corresponding html code:

Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long

Public Function HTMLColor(ByVal vbcolor As Long) As Long
 If vbcolor And &H80000000 Then
  vbcolor = GetSysColor(vbcolor And &HFFFFFF)
 End If
 HTMLColor = (vbcolor And &HFF0000) / &H10000 + (vbcolor And &HFF00&) + (vbcolor And &HFF&) * &H10000
End Function

Good luck!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

777 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