i have a datagrid and want to format the cell background colours which is working fine.

as you can see if the value of the cell is > 95 the cell goes green
if the cell value is < 90 the cell goes red.

i need help with anything between 95 and 90 i would like this to turn yellow

Dim cell As DataGridViewCell
        Dim CellVar As Double
        For Each row As DataGridViewRow In Me.OEEGrid.Rows
            cell = row.Cells("Yield")
            CellVar = CDbl(row.Cells("Yield").Value)
            If CellVar <= 90 Then
                cell.Style.BackColor = Color.Red
            ElseIf CellVar >= 95 Then
                cell.Style.BackColor = Color.Green
            End If
          
        Next

If you dont mind that my solution is a Select Statement instead then here you go:

Dim x As Double = CDbl(row.Cells("Yield").Value)

		Select Case x
			Case Is < 89
				Console.WriteLine("{0} is smaller than 90",x)
			Case 90 To 94
				Console.WriteLine("{0} is between 90 and 95",x)
			Case Is > 94
				Console.WriteLine("{0} is greater than or equal 95",x)
			Case Else

		End Select

Thanks for your quick responce, i am a newbie with .net

how would and where would i put this into my code?

thanks for your help i managed to get this working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.