Solved

HTML color code

Posted on 1998-07-03
3
352 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 100 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

707 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