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

x
?
Solved

How can I check picturebox backcolor ?

Posted on 2007-11-27
5
Medium Priority
?
248 Views
Last Modified: 2008-02-01
For example if picturebox1 backcolor is black then ....
0
Comment
Question by:waddhah
[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
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20358306
MsgBox Picture1.BackColor
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20358318
If Picture1.BackColor = vbBlack Then Picture1.BackColor = vbRed
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 20358320
Because Color has instance equality, you need to test the component values:

        Dim xColor as Color = Color.Blue

        If PictureBox1.BackColor.A = xColor.A _
            And PictureBox1.BackColor.R = xColor.R _
            And PictureBox1.BackColor.G = xColor.G _
            And PictureBox1.BackColor.B = xColor.B Then
            MsgBox("True")
        End If
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20358355
sorry. I had mistaken it for vb6
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 20358359
This demonstrates why you can't use BackColor = MyColor in a test:
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.BackColor = Color.Blue
        Dim xColor As Color = Color.FromArgb(255, 0, 0, 255)
 
        If PictureBox1.BackColor.A = xColor.A _
            And PictureBox1.BackColor.R = xColor.R _
            And PictureBox1.BackColor.G = xColor.G _
            And PictureBox1.BackColor.B = xColor.B Then
            MsgBox("True")
        End If
 
        If PictureBox1.BackColor = xColor Then
            MsgBox("True")
        Else
            MsgBox("False")
        End If
    End Sub
End Class

Open in new window

0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 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