Hi folks,
I usually use c# so I'm stuck on this.
I want a generic method that can handle dbnull's and return the default value for the type
I'n c# you can use the default key word but I can't find any vb version.
The following is what I would want to wrap up into a single method but without using lots of if, cases and gettypes if possible.
Public Function IntegerDefault(ByVal i As Integer) As Integer
If (IsDBNull(i)) Then
Return -1
Else
Return i
End If
End Function
Public Function StringDefault(ByVal s As String) As String
If (IsDBNull(s)) Then
Return ""
Else
Return s
End If
End Function
Cheers
Jon
I usually use c# so I'm stuck on this.
I want a generic method that can handle dbnull's and return the default value for the type
I'n c# you can use the default key word but I can't find any vb version.
The following is what I would want to wrap up into a single method but without using lots of if, cases and gettypes if possible.
Public Function IntegerDefault(ByVal i As Integer) As Integer
If (IsDBNull(i)) Then
Return -1
Else
Return i
End If
End Function
Public Function StringDefault(ByVal s As String) As String
If (IsDBNull(s)) Then
Return ""
Else
Return s
End If
End Function
Cheers
Jon