Solved

System.Drawing.Color Converting to Integer?

Posted on 2009-04-07
8
3,075 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 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24085324
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 100 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 400 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

738 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