mardi 21 août 2018

Use of operators >= and <= in Vb.net yielding a wrong result in if statement

I have this code:

  dim thck, thsp as Datatable    
  For i = 0 To TCList.Rows.Count - 1
  If thck.Rows(i)("Bond Coat") >= thsp.Rows(i)("BCmin") And thck.Rows(i)("Bond Coat") <= thsp.Rows(i)("BCMax") Then 
                    TCList.Rows(i).Cells("Bond Coat").Style.ForeColor = Color.Green
                Else
                    TCList.Rows(i).Cells("Bond Coat").Style.ForeColor = Color.Red
                End If
  Next

When thck.rows(i)("Bond Coat") = thsp.Rows(i)("BCMax") the cell gets colored in red, which in my opinion it doesn't make sense as the statement is true. Anyone can explain this behavior or how to fix this code without adding a thck.rows(i)("Bond Coat")+0.00001 to make the cell green? Code probably looks horrible, but I'm learning coming from a different background..

Aucun commentaire:

Enregistrer un commentaire