473,586 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("MyBack groundColor")
"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 1547
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********@hotm ail.com
http://www.nathansokalski.com/

"VB Programmer" <do**@emailme.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.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("MyBack groundColor")
"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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.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("MyBack groundColor")
"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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:et******** ******@TK2MSFTN GP14.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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.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("MyBack groundColor")
"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(ByVa l 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.c om> wrote in message
news:ue******** ******@tk2msftn gp13.phx.gbl...
Thanks everyone! You all rock!

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:et******** ******@TK2MSFTN GP14.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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.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("MyBack groundColor")
"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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eK******** ******@TK2MSFTN GP09.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(ByVa l 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.c om> wrote in message
news:ue******** ******@tk2msftn gp13.phx.gbl...
Thanks everyone! You all rock!

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:et******** ******@TK2MSFTN GP14.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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.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("MyBack groundColor")
"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
7261
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. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between...
2
8914
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) outputBank(0) = True outputBank(1) = False outputBank(2) = False
4
3615
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 of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and...
5
18516
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 tried the following and playing around with the following: declare @valuePointer varbinary(16)
3
10266
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 and there you have it. So I enquired and found the Convert class with it's promising ToInt32 method, great... but it doesn't work. The thing keeps...
7
66621
by: MilanB | last post by:
Hello How to convert char to int? Thanks
25
7251
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 Byte Dim b As Byte
7
29201
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
1407
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 declaration statments (first lines) e.g. Public Function ConvertCurrencyToEnglish(ByVal MyNumber As Double) As String Private Function...
5
8622
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 to the VB6 controls. In VB.NET, you can't set colors that way anymore, now you have to use a "color". There is a way to convert RGB values to a...
0
7841
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8204
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6617
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.