How do I check if a color has a certain amount of red (visual basic 2010) - vb.net

I'm trying to make an application where it detects if your mouse is on an object that is red. Not 100% red, but red.
currentclr = myBmp.GetPixel(MousePosition.X, MousePosition.Y)
this is what I use to find what color my mouse is on
For example, let's say I hover my mouse over a red object, if I convert it to string, it looks something like this
Color [A=232, R=201, G=15, B=15]
How do I check if the R is greater than 150?

Use:
if (currentclr.R > 150)

Related

Colors[4] not showing color selection on Front Panel

I am trying to set the color of an indicator to different colors based on different values, like 1 = red, 2 = blue etc. Using guidance from a Youtube video (accessible using this link: https://www.youtube.com/watch?v=czUmPQmKmGU), I have created a Colors[4] control for the indicator I have after changing it to the "write" function.
The Problem on the front panel is that I am getting a control with numbers instead of a color box where I can select the colors to show based on the value. This was the control I got instead.
This is the control I am trying to achieve (below):
Is there any way that I can get the color box on my control instead of the number controls? I am not sure if it can be changed through a control on the front panel or something but what I have tried so far keeps leading me back to this problem.
Any advice is much appreciated
A color box control is just a U32 number (three bytes for RGB and one which is always 0), which is why that's what you get.
There is a right click plugin which adds a replace with color box option directly to the right click menu of unsigned 32 bit numbers, but I don't remember if it ships with LV or not.
If you don't have that, you can always just right click the indicator inside the cluster, select replace and navigate the palettes to find the color box. You can also copy a color box and then select the indicator and paste, which replaces the selected control.
The color[4] is actually an array of 4 colors (UInt32 as Yair said), that define 2 color gradients, one for the 'Off' state, and the other for the 'On' State of the control.
If you want to set the control's color, you will have to define all 4 of them.

How can I convert system.drawing.color back to a string?

I have this code in Visual Basic working fine which saves a color that is selected from a ComboBox.text to My.Settings which is set to system.drawing.color.
My.Settings.SpecialColor = Color.FromName(ComboBoxSpecialColor.Text)
I am having trouble converting back to the ComboBox.text the color from the saved color in My.Settings.
ComboBoxSpecialColor.Text = My.Settings.SpecialColor(ToString)
I actually found a way for combo box to work but I was using lots of If else statements and typing in each color string to choose from. I was hoping there was an easier way because I have about 10 colors to select from in each combo box which i have 5 combo boxes and it was going to take about 50 if then else end if statements.
Does anyone know how to convert the my.settings color back to a string which can be placed in the combobox.text to display the right color?
This might point you in the right direction by removing parts of the string
https://msdn.microsoft.com/en-us/library/txha70f6(v=vs.90).aspx

Excel-VBA Red color labeled

I am trying to make a red label appear on my form and can not. I have tried changing the property to RGB and HEX and just get errors. Is there a way to get a property value to make my label RGB(200, 0, 0)? I am unaware of how the value in the property areas is developed.
This is the only way I can make a red label:
Private Sub Label13_Click()
Label13.BackColor = RGB(200, 0, 0)
End Sub
I have to click the label to make it red. Is there a way to use code to make it red when the form starts? Or perhaps generate a value for the property? Thank you for your help in advance.
You can use the Initialize event for the form instead of putting the event on a Click event.
Here is an example with the form named UserForm. Use the dropdowns to select the form and then the Initialize event.
You can also just set the color in the properties if you know this is the color you want.

SSRS Change cell color depending on SUM value

I am loading a dataset into my report and filling my last column with this expression: =Sum(Fields!ID.Value) and it loads fine, I am trying to put a condition in so when the number is less than 15 for example, the cell color will change to red. I have tried so many different syntax but nothing works... it must be pretty simple...?
The errors I am getting are: The value expression for textbox has scope parameter that is invalid for aggregate
Any help would be good :)
To set the background color Click on the cell and in properties window on your right hand select the BackgroundColor property and then set expression to that property.
Or right click on cell and select TextboxProperties -> Fill and at the start there is option to set the expression for fill color.
You are using the wrong expression the expression should be ,
= IIF(Sum(Fields!ID.Value) < 15,"Red","Transparent")
You can change the Transparent to whatever color you want.Take a look here on how to use expressions.
This shows how you could add a colour range if necessary by using the Color property to set the font colour.
=iif(Sum(Fields!ID.Value) < 15,"Red",iif(Sum(Fields!ID.Value)>50,"Blue","Black"))
To Change the background colour instead you would use the Background colour property.
=iif(Sum(Fields!ID.Value) < 15,"Red", "No Color")
Note that SSRS 2008 "Transaparent" is replaced by "No Color". Whilst transaparent works it gives rise to this warning message.
[rsInvalidColor] The value of the BackgroundColor property for the textbox ‘textbox22’ is “Transparent”, which is not a valid BackgroundColor.
As an alternative to these use "#FFFFFF" instead of Transaparent or No Color

ReportViewer Change Control color

I'm looking to change a control's color in my report.RDLC. My reports are all generated by the ReportViewer control on a form called "rv".
The selected rectangle below is the one I'm looking to change colors.
It has the following properties:
How do I programmatically change the Background color of the rectangle?
I figured it out after a few hours. On the control of which you want to change background colors, select the "Expression" link from the dropdown.
Afterwards you enter in the code such as:
=iif(Fields!State.Value = "Approved", "LightYellow", iif(Fields!State.Value = "Analysis", "LightGreen", "Transparent"))
This will set the color of my textbox to light yellow if it's state is "Approved", or light green if it is in it's analysis stage. If none of those are true, it just stays transparent (default).
*Note: My "State" field was added in my dataset so I was able to use it in the expression.