Function to convert to Integer while checking for null values

Virendradugar
Posted by Virendradugar under VB.NET category on | Views : 1940
Public Shared Function ToInteger(ByVal objVal As Object) As Integer
Try
If IsNothing(objVal) OrElse IsDBNull(objVal) Then
Return 0
Else
Return CInt(objVal)
End If
Catch ex As Exception
Throw ex
End Try
End Function

Comments or Responses

Login to post response