Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

System.Drawing.Color Converting to Integer?

Posted on 2009-04-07
8
Medium Priority
?
3,393 Views
Last Modified: 2013-12-26
I am using the colordialog to set the backcolor of a text box.
I use VB 2008 as the front end and MS Access as the backend.  
Can you convert the color to an integer or something that can be saved to the database and then easily set when the value is retrieved?
Please provide an example.  When I click on links my IE crashes.
Thanks
This is what I use to get the color... no idea on how to save it.
ColorDialog1.AllowFullOpen = True
        ColorDialog1.AnyColor = True
        ColorDialog1.SolidColorOnly = False
        ColorDialog1.ShowHelp = True
        If ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.txtCarColor.BackColor = ColorDialog1.Color
            Me.txtCarColor.Text = ColorDialog1.Color.Name.ToString
        End If

Open in new window

0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24085253
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24085318
POC should do for you:
            colorDialog1.ShowDialog();
            Color mycolor = colorDialog1.Color;
            int valuetoDb = mycolor.ToArgb();
           
            //save valuetodb into db

            Color getColorfrom = Color.FromArgb(valuetoDb);
0
 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24085324
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24085326
VB version:
colorDialog1.ShowDialog()
Dim mycolor As Color = colorDialog1.Color
Dim valuetoDb As Integer = mycolor.ToArgb()

'save valuetodb into db

Dim getColorfrom As Color = Color.FromArgb(valuetoDb)
0
 

Author Comment

by:Sheritlw
ID: 24090293
How do I convert it back to the color from the integer?
0
 
LVL 48

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 400 total points
ID: 24091828
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24092192
Its all there in :

POC should do for you:
            colorDialog1.ShowDialog();
            Color mycolor = colorDialog1.Color;
            int valuetoDb = mycolor.ToArgb();
           
            //save valuetodb into db
            //Convert back to color
            Color getColorfrom = Color.FromArgb(valuetoDb);
0
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 1600 total points
ID: 24092202
All there in (VB version)
VB version:
colorDialog1.ShowDialog()
Dim mycolor As Color = colorDialog1.Color
Dim valuetoDb As Integer = mycolor.ToArgb()

'save valuetodb into db
//Convert int back to color
Dim getColorfrom As Color = Color.FromArgb(valuetoDb)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question