-
Oct 4th, 2011, 05:49 PM
#1
Thread Starter
Hyperactive Member
Converting VB6 Colour (Integer) to VB.Net Colour
Hi all,
Just rewriting some old VB6 code into .Net. In the old code the database stored colours as Integers.
But now, when I retrieve the integer from the database, and try to assign to the VB.Net Color Object, it fails:
Code:
Dim g_lngMandatoryControlBackColour As Color
:
:
g_lngMandatoryControlBackColour = .Fields("MandatoryControlBackColour").Value ' FAILS HERE
Can someone please help me out with how to convert the Int to a Color?
thanks
Last edited by stingrae; Oct 4th, 2011 at 07:50 PM.
Reason: Resolved
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
-
Oct 4th, 2011, 07:06 PM
#2
Re: Converting VB6 Colour (Integer) to VB.Net Colour
Originally Posted by stingrae
Can someone please help me out with how to convert the Int to a Color?
Just a guess, maybe use the ColorTranslator class?
g_lngMandatoryControlBackColour = ColorTranslator.FromWin32(.Fields("MandatoryControlBackColour").Value )
-
Oct 4th, 2011, 07:16 PM
#3
Re: Converting VB6 Colour (Integer) to VB.Net Colour
The color hasn't changed. You are seeing a 32-bit color, most likely. You should be able to use:
.BackColor = System.Drawing.Color.FromARGB((.Fields("MandatoryControlBackColour").Value )
My usual boring signature: Nothing
-
Oct 4th, 2011, 07:50 PM
#4
Thread Starter
Hyperactive Member
Re: Converting VB6 Colour (Integer) to VB.Net Colour
Thanks guys. Worked!
w00t!
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|