473,396 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to convert to color?

How do I convert the following to a HEX code I can use in HTML documents?

1. [A=255, R=0, G=0, B=192]
2. Aqua

FYI: When I print the session variable I'm storing this color in (in the
Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"

Thanks!
Jan 3 '06 #1
5 1543
I don't think that there is a method to do that in the Color class. However,
if you plan on needing to do this more than a couple times I would simply
write your own function to do it. It wouldn't be hard, if you would like
help writing this function let me know. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"VB Programmer" <do**@emailme.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert the following to a HEX code I can use in HTML documents?

1. [A=255, R=0, G=0, B=192]
2. Aqua

FYI: When I print the session variable I'm storing this color in (in the
Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"

Thanks!

Jan 3 '06 #2
Hi VB Programmer,

First, you won't be able to use Alpha in an HTML document, so forget about
that part. As for creating a hexadecimal number from an RGB value, here's a
method I created that does this:

public static string ColorToHex(int R, int G, int B)
{
string r, g, b;
r = R.ToString("X2");
g = G.ToString("X2");
b = B.ToString("X2");
return "#" + r + g + b;
}

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"VB Programmer" <do**@emailme.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert the following to a HEX code I can use in HTML documents?

1. [A=255, R=0, G=0, B=192]
2. Aqua

FYI: When I print the session variable I'm storing this color in (in the
Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"

Thanks!

Jan 3 '06 #3
Thanks everyone! You all rock!

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:et**************@TK2MSFTNGP14.phx.gbl...
Hi VB Programmer,

First, you won't be able to use Alpha in an HTML document, so forget about
that part. As for creating a hexadecimal number from an RGB value, here's
a method I created that does this:

public static string ColorToHex(int R, int G, int B)
{
string r, g, b;
r = R.ToString("X2");
g = G.ToString("X2");
b = B.ToString("X2");
return "#" + r + g + b;
}

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"VB Programmer" <do**@emailme.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert the following to a HEX code I can use in HTML documents?

1. [A=255, R=0, G=0, B=192]
2. Aqua

FYI: When I print the session variable I'm storing this color in (in the
Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"

Thanks!


Jan 3 '06 #4
Hi VB Programmer,

Sorry, I just realized I gave you the code in C#. It sounds like you aren't
having any problems translating, but just in case:

Public Shared Function ColorToHex(ByVal R As Integer, _
ByVal G As Integer, ByVal B As Integer) As String
Dim red, blue, green As String
red = R.ToString("X2")
green = G.ToString("X2")
blue = B.ToString("X2")
Return "#" & red & green & blue
End Function

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"VB Programmer" <do**@emailme.com> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Thanks everyone! You all rock!

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:et**************@TK2MSFTNGP14.phx.gbl...
Hi VB Programmer,

First, you won't be able to use Alpha in an HTML document, so forget
about that part. As for creating a hexadecimal number from an RGB value,
here's a method I created that does this:

public static string ColorToHex(int R, int G, int B)
{
string r, g, b;
r = R.ToString("X2");
g = G.ToString("X2");
b = B.ToString("X2");
return "#" + r + g + b;
}

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"VB Programmer" <do**@emailme.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert the following to a HEX code I can use in HTML
documents?

1. [A=255, R=0, G=0, B=192]
2. Aqua

FYI: When I print the session variable I'm storing this color in (in
the Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"

Thanks!



Jan 3 '06 #5
Helpful as usual Kevin! Thanks.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
Hi VB Programmer,

Sorry, I just realized I gave you the code in C#. It sounds like you
aren't having any problems translating, but just in case:

Public Shared Function ColorToHex(ByVal R As Integer, _
ByVal G As Integer, ByVal B As Integer) As String
Dim red, blue, green As String
red = R.ToString("X2")
green = G.ToString("X2")
blue = B.ToString("X2")
Return "#" & red & green & blue
End Function

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"VB Programmer" <do**@emailme.com> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Thanks everyone! You all rock!

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:et**************@TK2MSFTNGP14.phx.gbl...
Hi VB Programmer,

First, you won't be able to use Alpha in an HTML document, so forget
about that part. As for creating a hexadecimal number from an RGB value,
here's a method I created that does this:

public static string ColorToHex(int R, int G, int B)
{
string r, g, b;
r = R.ToString("X2");
g = G.ToString("X2");
b = B.ToString("X2");
return "#" + r + g + b;
}

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"VB Programmer" <do**@emailme.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert the following to a HEX code I can use in HTML
documents?

1. [A=255, R=0, G=0, B=192]
2. Aqua

FYI: When I print the session variable I'm storing this color in (in
the Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"

Thanks!



Jan 4 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
2
by: Joel Moore | last post by:
Maybe I'm just easily baffled after an all-nighter but I can't seem to figure out how to represent a BitArray as a hexadecimal string. For example: Dim outputBank As New BitArray(8) ...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
5
by: Cally | last post by:
Hello, I would like to convert a field from ntext field found in one database table to float field found in another database table. The reason why I want to do this is a long one. I have...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: MilanB | last post by:
Hello How to convert char to int? Thanks
25
by: Charles Law | last post by:
I thought this was going to be straight forward, given the wealth of conversion functions in .NET, but it is proving more convoluted than imagined. Given the following <code> Dim ba(1) As...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
5
by: Bob Homes | last post by:
In VB6, foreground and background colors of controls had to be assigned a single number. If you knew the RGB values for the color, you still had to convert them into the single number accepatable...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.