473,386 Members | 1,819 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,386 software developers and data experts.

VB6 Color From Long - Equivalent in C#

Hi. Say, in VB6:

Const CLR2 As Long = &HFFF0DC ' light blue
AnyObj.BackColor = CLR2

- How is the equivalent one in C#?

Thanks,
<Harvey Triana />
Apr 20 '07 #1
4 9393
Harvey Triana wrote:
Hi. Say, in VB6:

Const CLR2 As Long = &HFFF0DC ' light blue
AnyObj.BackColor = CLR2

- How is the equivalent one in C#?

Thanks,
<Harvey Triana />

VB6 colors are BBGGRR, while .NET colors are RRGGBB. Also a .NET color
needs a value for the alpha channel, so you can create color from the
code, then create a solid color from that color:

Const colorTwo As Integer = &HDCF0FF
AnyObject.BackColor = Color.FromArgb(255, Color.FromArgb(colorTwo))

You can also create a color from the separate red, green and blue
components. Then you don't have to specify the alpha value:

AnyObject.BackColor = Color.FromArgb(&HDC, &HF0, &HFF)

--
Göran Andersson
_____
http://www.guffa.com
Apr 20 '07 #2
On Apr 20, 11:35 am, "Harvey Triana" <harveytri...@hotmail.comwrote:
Hi. Say, in VB6:

Const CLR2 As Long = &HFFF0DC ' light blue
AnyObj.BackColor = CLR2

- How is the equivalent one in C#?

Thanks,
<Harvey Triana />
Check out Color.FromARGB method.

Apr 20 '07 #3
Göran Andersson wrote:
Harvey Triana wrote:
>Hi. Say, in VB6:

Const CLR2 As Long = &HFFF0DC ' light blue
AnyObj.BackColor = CLR2

- How is the equivalent one in C#?

Thanks,
<Harvey Triana />

VB6 colors are BBGGRR, while .NET colors are RRGGBB. Also a .NET color
needs a value for the alpha channel, so you can create color from the
code, then create a solid color from that color:

Const colorTwo As Integer = &HDCF0FF
AnyObject.BackColor = Color.FromArgb(255, Color.FromArgb(colorTwo))

You can also create a color from the separate red, green and blue
components. Then you don't have to specify the alpha value:

AnyObject.BackColor = Color.FromArgb(&HDC, &HF0, &HFF)
Sorry, I gave you VB.NET code, here's the equivalent C# code:

const int colorTwo = 0xDCF0FF;
AnyObject.BackColor = Color.FromArgb(255, Color.FromArgb(colorTwo));

and

AnyObject.BackColor = Color.FromArgb(0xDC, 0xF0, 0xFF);

--
Göran Andersson
_____
http://www.guffa.com
Apr 20 '07 #4
Thanks a lot Göran

<Harvey Triana />
"Göran Andersson" <gu***@guffa.comescribió en el mensaje
news:eV*************@TK2MSFTNGP06.phx.gbl...
Göran Andersson wrote:
>Harvey Triana wrote:
>>Hi. Say, in VB6:

Const CLR2 As Long = &HFFF0DC ' light blue
AnyObj.BackColor = CLR2

- How is the equivalent one in C#?

Thanks,
<Harvey Triana />

VB6 colors are BBGGRR, while .NET colors are RRGGBB. Also a .NET color
needs a value for the alpha channel, so you can create color from the
code, then create a solid color from that color:

Const colorTwo As Integer = &HDCF0FF
AnyObject.BackColor = Color.FromArgb(255, Color.FromArgb(colorTwo))

You can also create a color from the separate red, green and blue
components. Then you don't have to specify the alpha value:

AnyObject.BackColor = Color.FromArgb(&HDC, &HF0, &HFF)

Sorry, I gave you VB.NET code, here's the equivalent C# code:

const int colorTwo = 0xDCF0FF;
AnyObject.BackColor = Color.FromArgb(255, Color.FromArgb(colorTwo));

and

AnyObject.BackColor = Color.FromArgb(0xDC, 0xF0, 0xFF);

--
Göran Andersson
_____
http://www.guffa.com

Apr 20 '07 #5

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

Similar topics

1
by: Edward WIJAYA | last post by:
Hi, I am new to Python, and I like to learn more about it. Since I am used to Perl before, I would like to know what is Python equivalent of Perl code below: $filename = $ARGV;
8
by: Tim Clacy | last post by:
How is a 64 bit type defined in strict C++? It seems C has support for 'long long' since C99, but not so for C++? Looking through one compiler vendor's standard library headers has clouded the...
13
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point,...
7
by: Rhino | last post by:
I am updating some Java UDFs from DB2GENERAL to DB2JAVA as suggested in the manuals for DB2 Version 8 but I'm having problems with setSQLstate() and setSQLmessage(). If I'm reading the manuals...
3
by: MLH | last post by:
What is the value of X immediately after declaring the variable? I thought its value was Null. However, I am unable to assign a value of Null to X... X = Null produces an error. I don't...
7
by: Kenjis Kaan | last post by:
I would like to use the crypt function in a Win32 (ie. C program using Visual C++ 6.0 compiler). I wrote a little program to see if it will link but it didn't. So I guess maybe the function isn't...
6
by: arkam | last post by:
Hi, I found a sample on internet : formMain.BeginInvoke(new MyClickHandler(this.OnMyClick)); I would like to do the same but in a class library where there is no forms ! Where can I find...
14
by: Allen | last post by:
Greetings, I need to pass a file path to an application. This file path contains long directory and file names. The target application, pdftotext.exe, only accepts short directory and file...
4
by: Kunle Odutola | last post by:
I'm trying to understand where the information in the META.INF directory including MANIFEST.MF etc is to be found for .NET assemblies. Also some projects such as Eclipse's OSGi kernel stores...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.