D
DaveS
Hi All!
Hopefully this is an easy question...
I am trying to convert input which is read in from a text file. All
data is read in as String. What I'm trying to do is safely convert
string data to integer data, if possible, or else return nothing. For
instance,
intDatum = ConvertToInt(strDatum)
where
Function ConvertToInt (ByVal strDatum as String) As Integer
Try
Return CInt(strDatum)
Catch
Return DBNull.Value
End Try
End Function
If strDatum = "3", then intDatum = 3
If strDatum = "?", then intDatum = Nothing (DBNull.Value, whatever
works...)
TIA,
DaveS
Hopefully this is an easy question...
I am trying to convert input which is read in from a text file. All
data is read in as String. What I'm trying to do is safely convert
string data to integer data, if possible, or else return nothing. For
instance,
intDatum = ConvertToInt(strDatum)
where
Function ConvertToInt (ByVal strDatum as String) As Integer
Try
Return CInt(strDatum)
Catch
Return DBNull.Value
End Try
End Function
If strDatum = "3", then intDatum = 3
If strDatum = "?", then intDatum = Nothing (DBNull.Value, whatever
works...)
TIA,
DaveS