Question : Operator '=' is not defined for type 'DBNull' and type 'Integer'.

I'm not sure how to check for null or empty in a comboboxcell that hold integer values. This is the error message I am getting:

Operator '=' is not defined for type 'DBNull' and type 'Integer'.

Here are the lines I have tried:

If Me.DataGridView.CurrentRow.Cells(0).Value.ToString = "" Then End If
If Me.DataGridView.CurrentRow.Cells(0).Value.ToString = vbNullString Then End If
If IsDBNull(Me.DataGridView.CurrentRow.Cells(0).Value) Then End If

I get the same error message with all these lines. Thanks in advance!

Answer : Operator '=' is not defined for type 'DBNull' and type 'Integer'.

Use "Is" for DBNull.Value, instead of "="

Example:
If Me.DataGridView.CurrentRow.Cells(0).Value Is DBNull.Value Then End If

Random Solutions  
 
programming4us programming4us