VB.NET2010:删除单元格数据时条件判断语句报错

VB.NET2010表格DataGridView2_CellValidating事件中

 If e.RowIndex >= 0 And IIf(IsDBNull(DataGridView2.CurrentCell.Value), "", DataGridView2.CurrentCell.Value) <> e.FormattedValue Then...

当我删除当前单元格内容时,
如果针对字符型字段OK,但是针对数值型字段出错提示如下:
从字符串“”到类型“Double”的转换无效
我试着改为:

 If e.RowIndex >= 0 And IIf(IsDBNull(.CurrentCell.Value), 0, .CurrentCell.Value) <> e.FormattedValue Then...

还是提示错误,怎么破?

主要是因为e.FormattedValue引起的,你改为

If e.RowIndex >= 0 And IIf(IsDBNull(DataGridView2.CurrentCell.Value), "", DataGridView2.CurrentCell.Value) <> e.FormattedValue.ToString()
Then

试试