我有这个方法: Private Function convertInteger(intInteger As Object) As Integer If IsDBNull(intInteger) Then convertInteger = 0 Else convertInteger = cInt(intInteger) End IfEnd Function 但它返回此错误: operator’=’未定义
Private Function convertInteger(intInteger As Object) As Integer If IsDBNull(intInteger) Then convertInteger = 0 Else convertInteger = cInt(intInteger) End If End Function
但它返回此错误:
operator’=’未定义类型’integer’并输入’dbnull’
我试图将DBnull值转换为0 ..
但问题是我试图转换的值并不总是DBnull ..所以我该如何处理呢?
试试这个Private Function convertInteger(intInteger As Object) As Integer If intInteger = DBNull.Value Then Return 0 End If Return intInteger End Function
正如[Tim Schmelter]所建议的,研究Nullable类型