Results 1 to 4 of 4

Thread: Converting VB6 Colour (Integer) to VB.Net Colour

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    Resolved 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

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Converting VB6 Colour (Integer) to VB.Net Colour

    Quote Originally Posted by stingrae View Post
    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 )

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    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

  4. #4

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    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
  •  



Click Here to Expand Forum to Full Width