Hello.
This is very easy, but not for me!
I have some numeric fields to compare with a number and act according to the result. But sometimes the field is missing and his value equals ""
In that case I have to compare a string ("") with a number, and CDbl does not convert my empty field. I know I can put before another conditional, but I suppose there must be a wiser way to do it.
My code is:
and I suppose it could be:
Thank you for your help.
This is very easy, but not for me!
I have some numeric fields to compare with a number and act according to the result. But sometimes the field is missing and his value equals ""
In that case I have to compare a string ("") with a number, and CDbl does not convert my empty field. I know I can put before another conditional, but I suppose there must be a wiser way to do it.
My code is:
VB.NET:
For x = 0 To 11
If Formdgv.dgv1.Rows(x).Cells("Column1").Value < 0.01 Then
Formdgv.dgv1.Rows(x).Cells("Column1").Style.ForeColor = Color.Green
End If
If Formdgv.dgv1.Rows(x).Cells("Column2").Value < 0.01 Then
Formdgv.dgv1.Rows(x).Cells("Column2").Style.ForeColor = Color.Green
End If
...
Next
and I suppose it could be:
VB.NET:
For x = 0 To 11
If Cstr(Formdgv.dgv1.Rows(x).Cells("Column1").Value) <> "" Then
If Formdgv.dgv1.Rows(x).Cells("Column1").Value < 0.01 Then
Formdgv.dgv1.Rows(x).Cells("Column1").Style.ForeColor = Color.Green
End If
End If
If Cstr(Formdgv.dgv1.Rows(x).Cells("Column2").Value) <> "" Then
If Formdgv.dgv1.Rows(x).Cells("Column2").Value < 0.01 Then
Formdgv.dgv1.Rows(x).Cells("Column2").Style.ForeColor = Color.Green
End If
End If
...
Next
Thank you for your help.
Last edited: