dc

dc

  • NA
  • 663
  • 0

vb.net need to convert string to integer

Aug 2 2019 10:56 AM
In a vb.net 2012 application I have the following code that works:
Protected _schoolyear As Integer
Protected _schoolyearcheck As String
If (IsDBNull(_schoolyearcheck)) Or (Not IsNumeric(_schoolyearcheck)) Or CInt(_schoolyearcheck < 2000) Or (CInt(_schoolyearcheck) = _schoolyear) Then
_schoolyear = _schoolyear
ElseIf CInt(_schoolyearcheck) + 1 = _schoolyear Then
_schoolyear = CInt(_schoolyearcheck)
End If
However I am wondering about the _schoolyearcheck field. I have a funciton call to the sql server database that really returns an integer value. However I
am concerned that the call may return a null or something that is not numeric. That is why I am using a string value. Due to that fact I am converting the
string to an interger in the the code Above. Thus can you show me code that would be better to use than converting all the values listed above?

Answers (1)