dc

dc

  • NA
  • 663
  • 0

vb.net 2010 code check if values exist

Jan 19 2017 5:57 PM

  In a vb.net 2010 application, I have the following code that works sometimes:
 Dim txtOrigAddress As String = _attendanceLetterOrig.Substring(CInt(_attendanceLetterOrig.IndexOf("ADDR_BEG")), _attendanceLetterOrig.IndexOf("ADDR_END") - _attendanceLetterOrig.IndexOf("ADDR_BEG"))
  Dim txtOrigAddress As String = _attendanceLetterOrig.Substring(CInt(_attendanceLetterOrig.IndexOf("ADDR_NEXT")),4)

 The problem is the folllowing values do not exist:
   _attendanceLetterOrig.IndexOf("ADDR_BEG")
  _attendanceLetterOrig.IndexOf("ADDR_END")
  _attendanceLetterOrig.Substring(CInt"ADDR_NEXT")

What kind of an edit can I use to check if the 3 values listed above actually exist sometimes? I want to prevent application errors.

Would you show me the code to see if the values really exist?


Answers (1)