Try statement not catching the exception vb.net -


my exception isn't working excel file searched , returned information. below see cycles through first column , returns information according variables set globally. have put exception if try fails message box pop , tell them failed find them, not catching it. instead if user isn't listed in database freezes program.

    private sub exceptiontoolstripmenuitem_click(byval sender system.object, byval e system.eventargs) handles exceptiontoolstripmenuitem.click      dim objexcel new excel.application     dim objworkbook excel.workbook     dim objworksheet excel.worksheet     objexcel.displayalerts = false      if global_variables.savedresults.userm = nothing , global_variables.savedresults.userl = nothing         objworkbook = objexcel.workbooks.open("filepath", [readonly]:=true)          objworksheet = ctype(objworkbook.worksheets.item("sheet1"), excel.worksheet)         try             x integer = 1 objworksheet.rows.count step 1                   if objworksheet.cells(x, 1).value = global_variables.savedresults.userd                      global_variables.savedresults.userl = objworksheet.cells(x, 3).value                     global_variables.savedresults.userm = objworksheet.cells(x, 2).value                      exit                 end if             next             exit try           catch ex exception             msgbox("you not in database.")         end try          objworkbook.close()         objexcel.quit()          releaseobject(objworksheet)         releaseobject(objworkbook)         releaseobject(objexcel)         objworkbook = nothing         objworksheet = nothing         objexcel = nothing     end if      dim email new email_templates     email.exception() end sub 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -