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?